Skip to main content

What is Context?

Context is a list of messages that tracks conversation history. Each message has a role (user, assistant, tool, system) and content.

Messages

Four message types:

Context Types

A1 uses three context types:
  • main: Clean successful execution history (user inputs + outputs)
  • attempt_*: Code generation/execution attempts (e.g., attempt_a, attempt_b)
  • intermediate_*: LLM calls from within generated code (e.g., intermediate_a)

When Messages Are Added

During JIT execution:
  • User input added to main at start
  • Assistant output added to main at end
  • Tool calls added to main during execution
During AOT compilation:
  • Nothing added to main context
  • Compilation attempts tracked in attempt_* contexts
  • Each candidate gets its own attempt context
During compiled tool execution:
  • Same as regular tool execution
  • Nothing added to main context (it’s just a tool)

Runtime

Runtime manages all contexts for a session:
Runtime handles:
  • Context lifecycle (creation, cleanup)
  • Named contexts (main, attempt_a, intermediate_a, etc.)
  • Context isolation between sessions

Persistence

Save and load contexts and runtime state: