Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix(agent): include model in structured response output (#4092)
* fix(agent): include model in structured response output

* fix(agent): update test expectation for model in structured response
  • Loading branch information
waleedlatif1 authored Apr 10, 2026
commit 3efbd1d6128773b1c264964fc32cba38de96cf59
1 change: 1 addition & 0 deletions apps/sim/executor/handlers/agent/agent-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ describe('AgentBlockHandler', () => {
expect(result).toEqual({
result: 'Success',
score: 0.95,
model: 'mock-model',
tokens: { input: 10, output: 20, total: 30 },
toolCalls: { list: [], count: 0 },
providerTiming: { total: 100 },
Expand Down
3 changes: 2 additions & 1 deletion apps/sim/executor/handlers/agent/agent-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1070,19 +1070,20 @@ export class AgentBlockHandler implements BlockHandler {
private processStandardResponse(result: any): BlockOutput {
return {
content: result.content,
model: result.model,
...this.createResponseMetadata(result),
...(result.interactionId && { interactionId: result.interactionId }),
}
}

private createResponseMetadata(result: {
model?: string
tokens?: { input?: number; output?: number; total?: number }
toolCalls?: Array<any>
timing?: any
cost?: any
}) {
return {
model: result.model,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metadata model field silently overwrites structured response data

Low Severity

Moving model into createResponseMetadata means it now gets spread over user-defined structured output in processStructuredResponse. Since metadata is spread after extractedJson, a user whose response schema includes a model field (e.g., product model, car model) will have that value silently overwritten by the provider's model identifier. Unlike the other metadata keys (tokens, toolCalls, providerTiming, cost), model is a common real-world field name, making collision more likely.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 3efbd1d. Configure here.

tokens: result.tokens || {
input: DEFAULTS.TOKENS.PROMPT,
output: DEFAULTS.TOKENS.COMPLETION,
Expand Down
Loading