Skip to main content
QitOS is configured through three overlapping layers:
  1. AgentModule.run() keyword arguments — the normal per-run entrypoint
  2. Engine constructor keyword arguments — lower-level runtime control
  3. Environment variables — provider credentials and model defaults

AgentModule.run() arguments

All of the following can be passed to agent.run(task, ...). This is the canonical user-facing configuration surface for QitOS runs.
ArgumentTypeDefaultDescription
taskstr | TaskrequiredTask objective string or structured Task object
max_stepsint | NoneNoneOverride TaskBudget.max_steps; also sets state.max_steps via state_kwargs
return_stateboolFalseReturn the full EngineResult instead of just state.final_result
workspacestr | NoneNonePath to workspace root; automatically constructs a HostEnv and sets env_spec on the task
envAnyNoneExplicit Env instance; takes precedence over workspace
ArgumentTypeDefaultDescription
parserAnyNoneParser instance (e.g. ReActTextParser, JsonDecisionParser) forwarded to the Engine
searchAnyNoneSearch strategy instance for branch decisions (e.g. DynamicTreeSearch)
criticsList[Any] | NoneNoneList of Critic instances evaluated after each step
stop_criteriaList[Any] | NoneNoneCustom stop criteria list; replaces the default FinalResultCriteria
history_policyAnyNoneHistoryPolicy instance controlling message history window
ArgumentTypeDefaultDescription
traceAnyNoneTrue to enable default TraceWriter; pass a TraceWriter instance for full control; False/None disables tracing only if trace_writer is not already set in engine_kwargs
trace_logdirstr"./runs"Directory where trace run subdirectories are created
trace_prefixstr | NoneNonePrefix for the auto-generated run ID; defaults to agent.name
renderAnyNoneTrue to enable the default ClaudeStyleHook render hook; pass a hook instance for custom rendering
themestr"research"Theme name passed to the render hook
ArgumentTypeDefaultDescription
hooksList[Any] | NoneNoneAdditional EngineHook instances appended to the Engine’s hook list
render_hooksList[Any] | NoneNoneAdditional render hook instances merged into hooks
engine_kwargsDict[str, Any] | NoneNoneAny Engine constructor keyword argument; lower-priority than the explicit arguments above
**state_kwargsAnyExtra keyword arguments forwarded to agent.init_state()
Minimal example
result = agent.run(
    task="Analyse the repository and list all public API functions.",
    workspace="/path/to/repo",
    max_steps=20,
    trace_logdir="./experiment-runs",
    trace_prefix="api-analysis",
)

Engine constructor arguments

When you construct an Engine directly (or via engine_kwargs), these parameters are available:
ParameterTypeDefaultDescription
agentAgentModulerequiredThe agent whose hooks the Engine calls
budgetRuntimeBudget | NoneRuntimeBudget(max_steps=10)Step, time, and token budgets for the run
validation_gateStateValidationGate | Nonedefault gateValidates state before and after each phase
recovery_handlerRecoveryHandler | NoneNoneCallable (state, phase, exc) -> None invoked on recoverable errors
recovery_policyRecoveryPolicy | NoneRecoveryPolicy()Controls retry behaviour and backoff
trace_writerTraceWriter | NoneNoneWrites trace artifacts; set via AgentModule.run(trace=True)
parserParser[ActionT] | NoneNoneConverts raw LLM output to Decision
stop_criteriaList[StopCriteria] | None[FinalResultCriteria()]Ordered stop criteria evaluated after each step
branch_selectorBranchSelector | NoneFirstCandidateSelector()Selects among branch candidates
searchSearch | NoneNoneSearch strategy for expanding and scoring branch candidates
criticsList[Critic] | None[]Critics evaluated after each step
envEnv | NoneNoneEnvironment for observe/step/is_terminal lifecycle
history_policyHistoryPolicy | NoneHistoryPolicy()Controls how history messages are assembled for model calls
hooksList[EngineHook] | None[]Engine lifecycle hooks
render_hooksList[Any] | NoneNoneRender hooks merged into hooks
RuntimeBudget fields
@dataclass
class RuntimeBudget:
    max_steps: int = 10
    max_runtime_seconds: Optional[float] = None
    max_tokens: Optional[int] = None
When a Task object is passed to Engine.run(), the Task.budget values override the Engine’s RuntimeBudget for that run.

Environment variables

VariableRequiredDescription
OPENAI_API_KEYYes (for OpenAI / compatible APIs)API key sent in the Authorization header. Used by OpenAIModel and OpenAICompatibleModel
OPENAI_BASE_URLYes (for compatible APIs)Base URL of the API endpoint. Required by OpenAICompatibleModel; optional for OpenAIModel (defaults to https://api.openai.com/v1)
QITOS_API_KEYNoAlternative API key variable. Recognized by ModelFactory.from_env() as a fallback when OPENAI_API_KEY is not set
QITOS_MODELNoDefault model identifier. Read by ModelFactory.from_env() to select the model when none is specified in code
AZURE_OPENAI_API_KEYOnly for AzureAPI key for Azure OpenAI. Used by AzureOpenAIModel
AZURE_OPENAI_ENDPOINTOnly for AzureEndpoint URL for Azure OpenAI
AZURE_OPENAI_DEPLOYMENTNoDeployment name for Azure OpenAI
AZURE_OPENAI_API_VERSIONNoAPI version; defaults to 2024-02-15-preview
Example .env file
# OpenAI-compatible endpoint (e.g. SiliconFlow, Ollama proxy)
OPENAI_API_KEY=sk-...
OPENAI_BASE_URL=https://api.siliconflow.cn/v1/

Trace output directory structure

By default, AgentModule.run() writes traces to ./runs/. Each run creates one subdirectory:
<trace_logdir>/
└── <trace_prefix>_<YYYYMMDD_HHMMSS_ffffff>/
    ├── manifest.json    # Run metadata and final summary
    ├── events.jsonl     # All runtime events (one JSON object per line)
    └── steps.jsonl      # All step records (one JSON object per line)
Auto-generated run ID format
<agent.name>_<YYYYMMDD_HHMMSS_ffffff>
Override the prefix with trace_prefix:
agent.run(task="...", trace_prefix="experiment-01")
# → runs/experiment-01_20260407_120000_123456/
Pointing qita board at your trace directory
qita board --logdir ./runs
Tracing is enabled by default in AgentModule.run(). Set trace=False only for quick interactive experiments — disabling tracing means runs cannot be replayed or inspected with qita.