Commit c9500a4
committed
refactor(agent-runtime): extract helpers from run-agent-step.ts (Commit 2.3)
Creates agent-step-helpers.ts with extracted functions:
- initializeAgentRun: Sets up agent template, system prompt, and tools
- buildInitialMessages: Constructs initial message history
- buildToolDefinitions: Converts ToolSet to serializable format
- prepareStepContext: Prepares context for an agent step (token counting)
- handleOutputSchemaRetry: Handles missing output schema validation
- Error utilities: extractErrorMessage, isPaymentRequiredError, getErrorStatusCode
Improvements:
- Adds comprehensive unit tests (35 tests) for all pure helpers
- Adds explicit interface types (InitializeAgentRunFullParams, SerializableToolDefinition, etc.)
- Adds JSDoc documentation with usage examples
- Organizes code with section headers
- Makes dependencies explicit in interface definitions1 parent 990494c commit c9500a4
File tree
3 files changed
+1332
-261
lines changed- packages/agent-runtime/src
- __tests__
3 files changed
+1332
-261
lines changed
0 commit comments