Skip to main content

Module provider

Module provider 

Source
Expand description

Implementation of toolpath-convo traits for Codex sessions.

The hard part is mapping Codex’s streaming event model onto toolpath_convo::Turn, which is message-shaped. The approach:

  1. Walk the rollout lines in order.
  2. response_item.message creates a new Turn. Role/content are mapped straightforwardly; developer becomes Role::System.
  3. response_item.reasoning is buffered and attached to the next assistant turn’s thinking field.
  4. response_item.function_call / custom_tool_call attach to the current turn (or a synthetic carrier if no message preceded them) as ToolInvocation entries. Output is back-filled when we see the matching *_output by call_id.
  5. event_msg.exec_command_end enriches the already-emitted tool invocation with the exit code / stdout / stderr.
  6. event_msg.patch_apply_end is captured on the current turn’s extra["codex"]["patch_changes"] — the derive layer consumes it for file-artifact sibling changes.
  7. event_msg.token_count populates Turn.token_usage on the next assistant turn emitted.
  8. Everything else (task_started, task_complete, turn_context, user_message/agent_message duplicates, unknown events) lands in ConversationView.events as a typed ConversationEvent.

Structs§

CodexConvo
Provider for Codex sessions.

Functions§

to_turn
Convert one rollout line to a “best-effort” Turn, if it carries one. Used by consumers who want per-line processing without the cross-line assembly that to_view does.
to_view
Convert a parsed Codex Session to the provider-agnostic ConversationView shape.
tool_category
Classify a Codex tool name into toolpath’s category ontology.