PtcRunner.SubAgent.Loop.TurnFeedback (PtcRunner v0.9.0)

Copy Markdown View Source

Turn feedback formatting for SubAgent execution.

Formats execution results and turn state information for LLM feedback. Supports the unified budget model with work turns and retry turns.

Uses Mustache templates from PtcRunner.Prompts:

  • must_return_warning/0 - Warning for final work turn
  • retry_feedback/0 - Turn info during retry phase

Summary

Functions

Append turn progress info to a feedback message.

Build error feedback with appropriate turn info based on unified budget model.

Format execution result feedback for the next LLM turn.

Render initial progress checklist (all pending) for the first user message.

Functions

append_turn_info(message, agent, state)

@spec append_turn_info(String.t(), PtcRunner.SubAgent.t(), map()) :: String.t()

Append turn progress info to a feedback message.

For multi-turn agents with retry_turns, shows unified budget info. For multi-turn agents without retry_turns, shows legacy turn count.

build_error_feedback(error_message, agent, state)

@spec build_error_feedback(String.t(), PtcRunner.SubAgent.t(), map()) :: String.t()

Build error feedback with appropriate turn info based on unified budget model.

This is used by the loop to format error messages with context about work/retry budgets.

format(agent, state, lisp_step)

@spec format(PtcRunner.SubAgent.t(), map(), map()) :: {String.t(), boolean()}

Format execution result feedback for the next LLM turn.

Returns {feedback_string, truncated?}.

Only shows explicit println output - the LLM must be intentional about what it inspects.

render_initial_progress(agent)

@spec render_initial_progress(PtcRunner.SubAgent.t()) :: String.t()

Render initial progress checklist (all pending) for the first user message.

Returns empty string if agent has no plan.