Unified execution loop for text output mode.
Text mode auto-detects the appropriate behavior from two signals:
| Tools? | Return type | Behavior |
|---|---|---|
| No | :string or none | Raw text response (single LLM call) |
| No | complex type | JSON response (validated against signature) |
| Yes | :string or none | Tool loop → text answer |
| Yes | complex type | Tool loop → JSON answer |
This module replaces the former JsonMode and ToolCallingMode.
Summary
Functions
@spec preview_prompt(PtcRunner.SubAgent.t(), map()) :: %{ system: String.t(), user: String.t(), tool_schemas: [map()], schema: map() | nil }
Generate a preview of the text mode prompts.
Returns the system and user messages that would be sent to the LLM, plus tool schemas and JSON schema when applicable.
@spec run(PtcRunner.SubAgent.t(), term(), map()) :: {:ok, PtcRunner.Step.t()} | {:error, PtcRunner.Step.t()}
Execute a SubAgent in text mode.
Auto-detects the variant based on tools and return type, then dispatches to the appropriate execution path.