Skip to content

feat(auto_ontology_agent): attribute Auto Ontology's model calls to their rollouts - #5648

Closed
ffrujeri wants to merge 4 commits into
ffrujeri/auto-ontology-agentfrom
ffrujeri/auto-ontology-rollout-attribution
Closed

ffrujeri wants to merge 4 commits into
ffrujeri/auto-ontology-agentfrom
ffrujeri/auto-ontology-rollout-attribution

Conversation

@ffrujeri

@ffrujeri ffrujeri commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Based on #5633 (the Auto Ontology Agent Server). Together they form the Auto Ontology stack. The diff against #5633 changes only responses_api_agents/auto_ontology_agent/.

What changed

Auto Ontology keeps one model client for each role for the whole process, and calls it from threads. So in #5633 its calls reach the Model Server without a rollout: no capture, no usage, and the close bundle declares model_call_ownership_unavailable and model_call_usage_unavailable. This PR attributes each call to its rollout and to the activation that made it, without per-episode clients.

  • The route of an activation (app.py). The Environment Server activates the session on its rollout's route, /ng-rollout/<capture key>, with the training-capture segment when training capture is on. The agent reads that prefix from the activation's path, as simple_agent does, and keeps it with the invocation ID (root, activation-2, ...) in a context variable for the turn. asyncio.to_thread and LangChain's executors copy the variable into Auto Ontology's threads.

  • The transport (model_calls.py). Auto Ontology's ChatOpenAI clients get an httpx transport. For each call it reads the route and sends the call through ServerClient.post on the agent's event loop, to /ng-rollout/<key>/v1/chat/completions with x-session-id: <invocation ID>. Gym then captures the call for its rollout and gives it to its invocation, and vLLM keeps the rollout's calls on one backend. The call goes over Gym's aiohttp client; httpx opens no connection (the transport-adapter pattern in AGENTS.md).

  • Auto Ontology's side (runtime.py). At the pinned revision, Auto Ontology takes neither an HTTP client nor an executor. When the agent imports it, send_model_calls_through sets two attributes of its modules:

    • It wraps llm_invoke._build_client, which builds every chat client, and gives each ChatOpenAI client the transport with the OpenAI SDK's with_options(http_client=...). Auto Ontology's base URL, timeout and retries stay.
    • It gives the coordinator LangChain's ContextThreadPoolExecutor, because apply_user_answer makes three model calls in a ThreadPoolExecutor that does not copy the context.

    A test checks both attributes against the real modules at the pinned revision. If Auto Ontology adds the two options, these become two plain calls.

  • Usage and gaps. Each response carries the summed usage of its activation's model calls, when every call reported usage. At close, the agent declares a gap only for missing evidence:

    • model_call_ownership_unavailable when an activation came without a rollout;
    • model_call_ownership_unavailable when a call lost its context while the session was open. The transport counts such calls and sends them without a rollout. It cannot tell whose call it was, so each session open at the time declares the gap.
    • model_call_usage_unavailable when a reply had no usage.
  • Model names. Only Auto Ontology's ChatOpenAI client can take the transport, so reasoning_model and fast_model must start with openai/, azure/ or aws/. The defaults are now openai/${policy_model_name} and openai/${auto_ontology_fast_model_name}. Gym's Model Servers send their own model name, so the prefix does not change the request the provider sees.

  • README. It has a new "Model calls" section. The capability level is Observability, not yet checked on saved rollouts. Training stays open: the training-capture route reaches every call, but how to train a policy on Auto Ontology's many separate calls is undecided (GYMINT-695).

Tracking: GYMINT-694. This design replaces the per-session clients that the issue proposes: Auto Ontology's clients stay shared for the process, and the route comes from the call's context. #4969 is not needed for this agent.

Validation

Check Result
pytest tests in the agent's locked venv 44 passed (30 before). New tests: two concurrent episodes whose calls come from the step's thread and from a LangChain executor each take their own route and invocation ID; a call from a ThreadPoolExecutor reaches the model without a rollout and is counted; a reply without usage leaves the usage unknown; a Model Server that does not reply in time times the call out; a call on the event loop or to another server is refused; through the agent, the activations' routes, the response usage and the close gaps (rollout route, no usage, no rollout, a call outside an activation); a model name that selects another client is refused; send_model_calls_through against the real Auto Ontology modules at the pinned revision
Each new behavior reverted in turn (rollout prefix, x-session-id, usage, context executor, client swap, the activation's route, both gaps) Each of the 8 reversions fails at least one test
Real Auto Ontology clients through the real transport, with only ServerClient faked: two concurrent episodes, each a text call and a structured-output call (invoke_with_structured_output) on the reasoning and fast clients, and a call from the coordinator's executor All 6 calls carried their own episode's route and invocation ID; each role reached its own Model Server; the structured output parsed; 0 calls without a route
gym env validate and gym env resolve for benchmarks/bird_interact/auto_ontology.yaml with the vLLM model config and stand-in settings Valid; Auto Ontology gets openai/<policy_model_name> for reasoning and openai/<auto_ontology_fast_model_name> for fast calls
pre-commit run on the changed files Passed

Rollout evidence

Not yet, as for #5633: a run needs Auto Ontology's catalog, filled for each database. The first c-Interact smoke on Docker sandboxes will run with observability_enabled: true and check that each rollout's captured calls join their invocations with no model-call gaps.

Compatibility

Changes only this agent. A config that set reasoning_model or fast_model without an openai/, azure/ or aws/ prefix now fails validation with a message that says how to fix it. With such a name, Auto Ontology would have used its ChatNVIDIA client, whose calls cannot carry a rollout.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Nov 5, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ffrujeri
ffrujeri added this pull request to stack #5649 November 5, 2026 00:35
@ffrujeri ffrujeri added area:agent Agent harnesses and Responses API agent behavior feature New capabilities, enhancements, or enablement work labels Nov 5, 2026
@ffrujeri

ffrujeri commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 3ea41a4

@ffrujeri

ffrujeri commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test a06a31f

@ffrujeri

ffrujeri commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test f7d5e80

@ffrujeri

ffrujeri commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test c681ac9

@ffrujeri
ffrujeri force-pushed the ffrujeri/auto-ontology-agent branch from 76bf403 to cd14901 Compare November 11, 2026 04:05
@ffrujeri
ffrujeri force-pushed the ffrujeri/auto-ontology-rollout-attribution branch from b91c7a0 to 9e9245a Compare November 11, 2026 04:05
@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 9e9245a

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 0bb46ee

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 0097564

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 82caea0

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 901dcbc

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 8c4cb19

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 363169e

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test b0ef817

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 53dc00f

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 0b8382a

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test f57b2bf

@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test c820a94

ffrujeri and others added 4 commits November 17, 2026 00:18
Auto Ontology, NVIDIA's text-to-SQL agent, runs in process as a Gym Agent
Server on the bird_interact Environment Server. In each turn the agent
steps Auto Ontology's interactive session until it submits, and runs each
action as the episode's ask_user or submit_sql tool. It reads the
BIRD-Interact ADK's c-Interact texts exactly and fails the activation on
a text it does not know.

benchmarks/bird_interact/auto_ontology.yaml pairs it with BIRD-Interact
Lite in c-Interact. The agent installs Auto Ontology from its repository
at the revision auto-ontology-eval pins, and copies auto-ontology-eval's
BIRD-Interact feature flags. scripts/component-lock-policy.json keeps
sqlalchemy and alembic in the agent's lock, because Auto Ontology's
catalog code imports them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…Model Server

Auto Ontology has two model roles. The reasoning model decides what to
ask and what SQL to submit, so it is the policy and runs on policy_model.
The fast model makes helper calls (merging the user's answers into the
question, evidence checks, structured extraction). It fell back to the
reasoning model's server, so the evaluated policy also served those
calls. It now runs on its own Model Server, auto_ontology_fast_model,
configured in env.yaml like the simulator's user_model, as
auto-ontology-eval runs a separate fast model beside its reasoning model.
fast_model_server and fast_model are required, so the fast role never
falls back to the policy silently.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…ts that serve agent sessions

Main checks that every agent app that seeds agent sessions is in
AGENT_SESSION_AGENT_TYPES, which decides how a session environment
wires the agent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
…heir rollouts

Auto Ontology keeps one model client for each role for the whole process
and calls it from threads, so its calls reached the Model Server without
a rollout. The agent now gives those clients an httpx transport that sends
each call through ServerClient on the agent's event loop, on the route of
the activation that made it: the activation's rollout prefix (with the
training-capture segment when that is on) and its invocation ID as
x-session-id. The route travels in a context variable that asyncio's and
LangChain's executors copy into Auto Ontology's threads.

At the pinned revision Auto Ontology takes neither an HTTP client nor an
executor, so the agent wraps llm_invoke._build_client and gives the
coordinator LangChain's ContextThreadPoolExecutor when it imports Auto
Ontology. Model names must select Auto Ontology's ChatOpenAI client.

Responses now carry usage. The close bundle declares a model-call gap only
when evidence is missing: an activation without a rollout, a call that
lost its context while the session was open, or a reply without usage.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Felipe Vieira Frujeri <[email protected]>
@ffrujeri

Copy link
Copy Markdown
Contributor Author

/ok to test 5b9194e

@ffrujeri

Copy link
Copy Markdown
Contributor Author

Closing: this is now part of the Auto Ontology agent itself. With Auto Ontology's ReAct agent, the agent builds the chat clients and gives them a transport that sends each model call through Gym's ServerClient on the activation's rollout route (model_calls.py), so the patches of the old pipeline are gone. The agent is #6271 (on main, BIRD dev); #5633 adds its c-Interact mode for BIRD-Interact.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent harnesses and Responses API agent behavior feature New capabilities, enhancements, or enablement work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant