Skip to content

models.corp backend & harness - #16

Open
jctanner wants to merge 20 commits into
mainfrom
feature/modelscorp-backend
Open

jctanner wants to merge 20 commits into
mainfrom
feature/modelscorp-backend

Conversation

@jctanner

Copy link
Copy Markdown
Owner

No description provided.

jctanner and others added 20 commits May 15, 2026 14:09
Add implementation plan for a custom Python agent harness that
integrates Models.Corp (OpenAI-compatible API) as a third backend
alongside Claude Code and Codex CLIs. Gitignore confidential/ dir
and .modelscorp.json credential config.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New agent backend for Red Hat's Models.Corp platform, which exposes
OpenAI-compatible endpoints. Includes:

- container/modelscorp_agent.py: Python agent harness implementing
  the agentic tool-calling loop (MCP tool discovery via JSON-RPC,
  OpenAI SDK for LLM calls, JSONL output)
- ModelscorpBackend class in agent_backends.py
- Model shorthand mappings (granite-micro, qwen3, etc.)
- Dockerfile and CLI updates for the new backend
- .modelscorp.json.example for per-model credential configuration

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…l calls

- Disable SSL verification for internal certs (Models.Corp uses
  Red Hat internal CA)
- Add model_id config field to separate URL slug from API model name
  (e.g. URL uses granite-4-0-micro, API needs ibm-granite/granite-4.0-micro)
- Parse <tool_call> tags from text output for models like Granite
  that don't support native OpenAI function calling
- Update .modelscorp.json.example with correct endpoint_type and model_id

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…gent enabled flag

- Fix MCP 406 errors by adding Accept header and json_response=True to FastMCP
- Fix Granite double-encoded tool call arguments in parse_text_tool_calls
- Fix Gemini URL routing: don't append /v1 when base_path is set
- Add per-agent allowed_tools filtering (scenario.yaml -> harness --allowed-tools)
- Fix allowed_tools not being passed: scenario_loader was dropping the field
- Add enabled: false flag to scenario.yaml to disable agents without removing them
- Add file logging for Flask and MCP servers (var/, not var/logs/ which gets wiped)
- Reset server logs on startup (mode="w")
- Update model-test scenario: add 5 Models.Corp agents (Granite 4.0-Micro/Tiny,
  Qwen3-14B, Llama 3.3-70B, Gemini 2.5-Pro), disable broken models (Granite 3.3-8B,
  Mistral 7B) that lack native function calling support
- Fix backend type detection in orchestrator for ModelscorpBackend
- Propagate allowed_tools in hire-agent path

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add _normalize_channel() to auto-prepend # when models drop the prefix
  (Gemini 2.5-Pro passes "general" instead of "#general", causing 400 errors
  on post_message while get_messages silently worked)
- Apply normalization to post_message, get_messages, join_channel,
  get_channel_members
- Enable all 10 functional agents: Claude (Opus/Sonnet/Haiku), Codex
  (GPT-5.5/5.4-mini), Models.Corp (Gemini/Llama-70B/Qwen3-14B/Granite-4.0
  Micro+Tiny) with tiered response ordering
- Give Quinn (Qwen3), Lana (Llama-70B), and Gemma (Gemini) access to
  chat + docs + gitlab tools (24 tools vs 58)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds ConversationMemory ABC with FIFOMemory (pinned system prompt +
sliding window) and NoMemory (stateless pass-through) strategies.
Session IDs are assigned at container startup and passed to the harness,
matching the Claude/Codex session pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rash

Break the agent loop immediately after signal_done is executed, preventing
models from re-reading and re-posting. Strip tool_calls and tool responses
from FIFO history to avoid Gemini's strict message ordering constraint.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…loosened character prompts

Rewrites model-test scenario: role-based personas replaced with personality-only
prompts + anti-hallucination rules, persona keys renamed from roles to names
(engineer→codey, etc.), adds Oscar (Opus) and Darcy (GPT-5.5) as eval subjects.

Adds #judges private channel and per-agent #eval-{name} channels with tiered
response (Tier 1 subjects, Tier 2 Opie, Tier 3 Dexy). Includes a single eval
event that instructs judges to coordinate, design chat-only tests, and produce
a report.

Implements per-agent fallback_channel config: when a Models.Corp agent produces
text but never calls post_message, the harness auto-posts to the triggering
channel. Configured in scenario.yaml, loaded through scenario_loader, passed
to the modelscorp_agent.py harness via --fallback-channel.

Also adds build-agent Makefile target and enables --use-sessions by default.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…flexion

Completes the composable conversation memory architecture for cosim_agent:
- Phase 1: NoMemory, FIFOMemory (pinning, tool-clearing, atomic groups),
  SummaryMemory, SummaryBufferMemory
- Phase 2: DecayMemory (exponential decay scoring), EntityMemory (LLM entity
  extraction), EpisodicMemory (periodic reflections), ReflexionMemory
  (per-turn self-critique)

Includes cosim_agent package with MCP client, agent harness, and 103 tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- New memory-eval scenario with 3 judge agents (2 Opus + 1 Sonnet) that
  hire test agents with different memory strategies and evaluate recall,
  coherence, and context tracking
- Add memory and allowed_tools params to hire_agent MCP tool
- Auto-create channels on hire when they don't exist yet
- Add SSE broadcast for dynamically created channels
- Frontend handler to display new channels without page reload

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Root cause: when judges called hire_agent during a response cycle,
the add_agent commands queued in Flask but couldn't be processed
until _run_loop returned. Meanwhile _run_loop kept triggering judges
for eval channels (since they joined them), creating an infinite loop
where judges responded to their own messages while hired agents never
got created.

Three fixes:

1. Process add_agent commands between tiers inside _run_loop (the key
   fix). After each tier completes, drain add_agent commands from the
   queue so newly hired agents are in the pool before the next wave.
   This breaks the deadlock.

2. Assign session IDs for hired agents (missing from _process_single_command
   but present in pool.start). Without this, memory config was never passed
   via --memory-config to the cosim-agent process.

3. Add error handling around container launch in _process_single_command.
   Previously a podman failure would crash the entire orchestrator.

4. Add catch-up trigger after processing add_agent in the main loop —
   checks if newly added agents have unread messages in their channels
   and triggers a response loop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…e/fire

Dynamic hiring was causing cascading issues (session IDs, deadlocks,
fallback channels, granite models not calling post_message). Replace with
4 pre-configured test agents (none/fifo/summary-buffer/entity memory)
and enable fallback_channel auto-posting for all modelscorp agents.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Test agents see all messages in their channel, so evaluator commentary
would pollute their context and contaminate results.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
New `documents` section in scenario.yaml lets scenarios ship with
pre-seeded documents that get copied into var/docs/ at startup.
Memory-eval scenario now includes the test protocol and scoring rubric
so judges can execute immediately instead of reinventing them each run.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Test agents shouldn't see scoring criteria or what's being tested.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Judges were self-starting because their character prompts contained the
full evaluation context. Now prompts define only personality and role;
all task specifics come from the Scenario Director event. Judges are
explicitly told to wait for instructions before beginning work.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Display names, team descriptions, channel descriptions, and folder
descriptions were leaking enough context for judges to infer the full
evaluation setup before the event fired. Now all structural metadata
is generic — specifics only arrive via the Scenario Director event.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Incorporates 7 amendments from the judges' pre-execution review:
- Binary scoring as primary, 0-5 scale as diagnostic taxonomy
- Semantic matching rules for entity attributes
- Strict END OF REPORT acceptance criteria
- Concrete pass/fail examples for Test 4
- Personal-recall filler questions (T8, T15) to control format confound
- Three-step tiebreaker procedure with conservative scoring
- Dual reporting: raw totals + normalized equal-weight scores

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant