Skip to content

feat(codex): send the response and request settings of each model request - #333

Merged
gangtao merged 1 commit into
mainfrom
feat/codex-llm-response-content
Nov 30, 2026
Merged

gangtao merged 1 commit into
mainfrom
feat/codex-llm-response-content

Conversation

@gangtao

@gangtao gangtao commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Closes #332. The Codex half of #330; the Claude Code half was #331.

What changes

On PostModelRequest the plugin reads the response of that request from the rollout file (transcript_path) and adds it to the event:

hooks export (event_data) otel export (span attribute) Content
response.text agentguard.response.text Assistant text, cut to AGENTGUARD_LLM_CONTENT_CHARS (default 4000); left out with AGENTGUARD_LLM_CONTENT=false
response.text_chars agentguard.response.text_chars Length before the cut
response.tool_calls agentguard.response.tool_calls (JSON) [{id, name}], the id is the transcript's call_id
response.phase agentguard.response.phase commentary / final_answer
request.effort, request.summary agentguard.request.effort, .summary Reasoning settings of the turn
  • New module agentguard_codex/transcript.py. It reads only the last 8 MB of the file.
  • The request is found by its turn and token counts, because the hook's request_id is not known to match the rollout's response_id. When it is not found, the event is sent as before.
  • The span attributes are not OpenInference's llm.output_messages, so the app's current views do not start showing commentary before a tool call as the assistant message. The app opts in when it reads the new names.
  • Version 0.4.0. Docs: plugin README, docs/plugin-install.md, docs/cim.md, the skill, CLAUDE.md.

Tested

  • Unit tests: 110 run, 12 skipped (the ones that need the SDK), all pass.
  • Replay of 26 local Codex 0.172.0 sessions (2,195 model requests, files up to 72 MB): every request matched when the file is cut where the hook would see it. A read takes about 25 ms on the largest file.
  • The CLI end to end on the hooks export against a local capture server, with a real rollout file.

Not tested

  • Whether the response lines are in the file when PostModelRequest fires. Codex does not run a new hook until it is trusted in /hooks, so this was not run inside a live Codex session. If the lines arrive later, the plugin waits up to 0.5 s per model request (Codex waits for the hook) and then sends the event without the new fields.
  • The otel export against a real collector.
  • Hooks fired inside a sub-agent.

🤖 Generated with Claude Code

…uest

On PostModelRequest the plugin reads the response of that request from the
rollout file and adds its text, the tool calls it asked for (id and name),
the phase and the turn's reasoning settings: response / request in event_data
on the hooks export, agentguard.response.* / agentguard.request.* span
attributes on the otel export.

The hook payload and the rollout file share no id that is known to match, so
the request is found by its turn and token counts, with a wait of up to 0.5 s
for lines that are not written yet. When it is not found the event is sent as
before.

AGENTGUARD_LLM_CONTENT=false leaves the text out; AGENTGUARD_LLM_CONTENT_CHARS
sets the cut (default 4000). Version 0.4.0.

Closes #332

Co-Authored-By: Claude Fable 5.2 <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.

Codex plugin: send the response and request settings of each model request

1 participant