|
| 1 | +import { createBase2 } from '../base2' |
| 2 | +import type { SecretAgentDefinition } from '../../types/secret-agent-definition' |
| 3 | +import { ToolCall } from '../../types/agent-definition' |
| 4 | + |
| 5 | +const base2 = createBase2('fast') |
| 6 | +const definition: SecretAgentDefinition = { |
| 7 | + ...base2, |
| 8 | + id: 'base2-alloy2', |
| 9 | + spawnableAgents: [ |
| 10 | + ...(base2.spawnableAgents ?? []), |
| 11 | + 'base2-plan-step', |
| 12 | + 'base2-plan-step-gpt-5', |
| 13 | + ], |
| 14 | + stepPrompt: `${base2.stepPrompt} |
| 15 | +
|
| 16 | +## Spawned planner agents have generated potential next steps |
| 17 | +
|
| 18 | +Two hypothetical next steps have been generated from planner agents (base2-plan-step and base2-plan-step-gpt-5). Use them as inspiration to write out your own next step. Feel free to take the best parts of each step or ignore them, but know that none of what they wrote out has taken any effect, and it's up to you to write out the actual next step that the user will see.`, |
| 19 | + |
| 20 | + handleSteps: function* ({ params, logger }) { |
| 21 | + while (true) { |
| 22 | + // Run context-pruner before each step |
| 23 | + yield { |
| 24 | + toolName: 'spawn_agent_inline', |
| 25 | + input: { |
| 26 | + agent_type: 'context-pruner', |
| 27 | + params: params ?? {}, |
| 28 | + }, |
| 29 | + includeToolCall: false, |
| 30 | + } as any |
| 31 | + |
| 32 | + yield { |
| 33 | + toolName: 'spawn_agents', |
| 34 | + input: { |
| 35 | + agents: [ |
| 36 | + { |
| 37 | + agent_type: 'base2-plan-step', |
| 38 | + }, |
| 39 | + { |
| 40 | + agent_type: 'base2-plan-step-gpt-5', |
| 41 | + }, |
| 42 | + ], |
| 43 | + }, |
| 44 | + } |
| 45 | + |
| 46 | + const { stepsComplete, agentState } = yield 'STEP' |
| 47 | + |
| 48 | + // Remove the spawn & spawn result for the base2-plan-step agents |
| 49 | + const spawnResultIndex = agentState.messageHistory.findLastIndex( |
| 50 | + (m) => |
| 51 | + m.role === 'tool' && |
| 52 | + m.content.toolName === 'spawn_agents' && |
| 53 | + m.content.output[0].type === 'json' && |
| 54 | + (m.content.output[0].value as any[])[0]?.agentType === |
| 55 | + 'base2-plan-step', |
| 56 | + ) |
| 57 | + |
| 58 | + const updatedMessageHistory = agentState.messageHistory.concat() |
| 59 | + updatedMessageHistory.splice(spawnResultIndex - 1, 2) |
| 60 | + |
| 61 | + yield { |
| 62 | + toolName: 'set_messages', |
| 63 | + input: { |
| 64 | + messages: updatedMessageHistory, |
| 65 | + }, |
| 66 | + includeToolCall: false, |
| 67 | + } satisfies ToolCall<'set_messages'> |
| 68 | + |
| 69 | + if (stepsComplete) break |
| 70 | + } |
| 71 | + }, |
| 72 | +} |
| 73 | + |
| 74 | +export default definition |
0 commit comments