You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(agent-runtime): extract helpers from run-agent-step.ts (Commit
2.3)
Extract helper functions from loopAgentSteps to improve readability and
testability:
- initializeAgentRun: Agent template resolution, run initialization,
system prompt generation
- buildInitialMessages: Initial message history construction
- buildToolDefinitions: Tool definitions for token counting
- prepareStepContext: Token counting and step prompt preparation
- handleOutputSchemaRetry: Output schema validation and retry logic
- extractErrorMessage, isPaymentRequiredError, getErrorStatusCode: Error
handling utilities
The main loopAgentSteps function is now organized into clear phases:
1. Initialize Agent Run
2. Build Initial Messages
3. Agent Step Loop
4. Finalize Run
This refactoring maintains full backwards compatibility while reducing
the
cognitive load of understanding the agent execution flow.
🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
0 commit comments