Skip to content

Commit 901ebb5

Browse files
committed
Update agent-definition.ts
1 parent 637cce4 commit 901ebb5

File tree

2 files changed

+36
-15
lines changed

2 files changed

+36
-15
lines changed

.agents/types/agent-definition.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ import type * as Tools from './tools'
1818
import type { Message, ToolResultOutput, JsonObjectSchema } from './util-types'
1919
type ToolName = Tools.ToolName
2020

21+
// ============================================================================
22+
// Logger Interface
23+
// ============================================================================
24+
25+
export interface Logger {
26+
debug: (data: any, msg?: string) => void
27+
info: (data: any, msg?: string) => void
28+
warn: (data: any, msg?: string) => void
29+
error: (data: any, msg?: string) => void
30+
}
31+
2132
// ============================================================================
2233
// Agent Definition and Utility Types
2334
// ============================================================================
@@ -144,14 +155,16 @@ export interface AgentDefinition {
144155
* Or use 'return' to end the turn.
145156
*
146157
* Example 1:
147-
* function* handleSteps({ agentStep, prompt, params}) {
158+
* function* handleSteps({ agentStep, prompt, params}, logger) {
159+
* logger.info('Starting file read process')
148160
* const { toolResult } = yield {
149161
* toolName: 'read_files',
150162
* input: { paths: ['file1.txt', 'file2.txt'] }
151163
* }
152164
* yield 'STEP_ALL'
153165
*
154166
* // Optionally do a post-processing step here...
167+
* logger.info('Files read successfully, setting output')
155168
* yield {
156169
* toolName: 'set_output',
157170
* input: {
@@ -161,8 +174,9 @@ export interface AgentDefinition {
161174
* }
162175
*
163176
* Example 2:
164-
* handleSteps: function* ({ agentState, prompt, params }) {
177+
* handleSteps: function* ({ agentState, prompt, params }, logger) {
165178
* while (true) {
179+
* logger.debug('Spawning thinker agent')
166180
* yield {
167181
* toolName: 'spawn_agents',
168182
* input: {
@@ -218,16 +232,6 @@ export interface AgentStepContext {
218232
params?: Record<string, any>
219233
}
220234

221-
/**
222-
* Logger interface for handleSteps
223-
*/
224-
export interface Logger {
225-
debug: (data: any, msg?: string) => void
226-
info: (data: any, msg?: string) => void
227-
warn: (data: any, msg?: string) => void
228-
error: (data: any, msg?: string) => void
229-
}
230-
231235
/**
232236
* Tool call object for handleSteps generator
233237
*/

common/src/templates/initial-agents-dir/types/agent-definition.ts

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ import type * as Tools from './tools'
1818
import type { Message, ToolResultOutput, JsonObjectSchema } from './util-types'
1919
type ToolName = Tools.ToolName
2020

21+
// ============================================================================
22+
// Logger Interface
23+
// ============================================================================
24+
25+
export interface Logger {
26+
debug: (data: any, msg?: string) => void
27+
info: (data: any, msg?: string) => void
28+
warn: (data: any, msg?: string) => void
29+
error: (data: any, msg?: string) => void
30+
}
31+
2132
// ============================================================================
2233
// Agent Definition and Utility Types
2334
// ============================================================================
@@ -144,14 +155,16 @@ export interface AgentDefinition {
144155
* Or use 'return' to end the turn.
145156
*
146157
* Example 1:
147-
* function* handleSteps({ agentStep, prompt, params}) {
158+
* function* handleSteps({ agentStep, prompt, params}, logger) {
159+
* logger.info('Starting file read process')
148160
* const { toolResult } = yield {
149161
* toolName: 'read_files',
150162
* input: { paths: ['file1.txt', 'file2.txt'] }
151163
* }
152164
* yield 'STEP_ALL'
153165
*
154166
* // Optionally do a post-processing step here...
167+
* logger.info('Files read successfully, setting output')
155168
* yield {
156169
* toolName: 'set_output',
157170
* input: {
@@ -161,8 +174,9 @@ export interface AgentDefinition {
161174
* }
162175
*
163176
* Example 2:
164-
* handleSteps: function* ({ agentState, prompt, params }) {
177+
* handleSteps: function* ({ agentState, prompt, params }, logger) {
165178
* while (true) {
179+
* logger.debug('Spawning thinker agent')
166180
* yield {
167181
* toolName: 'spawn_agents',
168182
* input: {
@@ -179,7 +193,10 @@ export interface AgentDefinition {
179193
* }
180194
* }
181195
*/
182-
handleSteps?: (context: AgentStepContext) => Generator<
196+
handleSteps?: (
197+
context: AgentStepContext,
198+
logger: Logger,
199+
) => Generator<
183200
ToolCall | 'STEP' | 'STEP_ALL',
184201
void,
185202
{

0 commit comments

Comments
 (0)