Skip to content

Commit 019a771

Browse files
committed
Fix set output
1 parent e423dcf commit 019a771

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

backend/src/tools/handlers/set-output.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import { AgentState } from '@codebuff/common/types/session-state'
22
import { logger } from '../../util/logger'
33
import { CodebuffToolCall, CodebuffToolHandlerFunction } from '../constants'
4-
import { agentRegistry } from '../../templates/agent-registry'
4+
import { getAllAgentTemplates } from '../../templates/agent-registry'
5+
import { ProjectFileContext } from '@codebuff/common/util/file'
56

67
export const handleSetOutput = ((params: {
78
previousToolCallFinished: Promise<void>
89
toolCall: CodebuffToolCall<'set_output'>
10+
fileContext: ProjectFileContext
911
state: {
1012
agentState?: AgentState
1113
}
1214
}): {
1315
result: Promise<string>
1416
state: { agentState: AgentState }
1517
} => {
16-
const { previousToolCallFinished, toolCall, state } = params
17-
const output = toolCall.args // The entire args object is the output
18+
const { previousToolCallFinished, toolCall, state, fileContext } = params
19+
const output = toolCall.args
1820
const { agentState } = state
1921

2022
if (!agentState) {
@@ -24,9 +26,12 @@ export const handleSetOutput = ((params: {
2426
}
2527

2628
const triggerSetOutput = async () => {
29+
const { agentRegistry } = await getAllAgentTemplates({
30+
fileContext,
31+
})
2732
// Validate output against outputSchema if defined
2833
const agentTemplate = agentState.agentType
29-
? agentRegistry.getTemplate(agentState.agentType)
34+
? agentRegistry[agentState.agentType]
3035
: null
3136
if (agentTemplate?.outputSchema) {
3237
try {

0 commit comments

Comments
 (0)