Skip to content

fix(agent): include model in structured response output#4092

Merged
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/fix-custom-response-model
Apr 10, 2026
Merged

fix(agent): include model in structured response output#4092
waleedlatif1 merged 2 commits intostagingfrom
waleedlatif1/fix-custom-response-model

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Moved model into createResponseMetadata so it's included in both standard and structured (custom response format) agent outputs
  • Previously agent.model was missing when a custom response format was provided

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 10, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 10, 2026 5:43am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 10, 2026

PR Summary

Low Risk
Low risk: small change to agent response shaping that adds model to metadata for structured responses; minimal behavioral impact beyond an extra output field.

Overview
Agent responses now always include the provider model by moving it into createResponseMetadata, so structured (responseFormat) JSON outputs get the same metadata as standard outputs.

Tests were updated to assert model is present in structured response results.

Reviewed by Cursor Bugbot for commit b8251a4. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 10, 2026

Greptile Summary

This PR fixes a bug where the model field was absent from agent block outputs when a custom response format (responseFormat) was provided. The fix moves model: result.model from processStandardResponse into createResponseMetadata so it is emitted by both the standard and structured response code paths. A matching test assertion (model: 'mock-model') was added to verify the structured response path now includes the field.

Confidence Score: 5/5

Safe to merge — minimal, targeted bug fix with a matching test covering the previously untested code path.

The change is a single-field relocation with no behavioral regressions on the standard path and a clear fix for the structured response path. No P0 or P1 findings identified.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/executor/handlers/agent/agent-handler.ts Moved model field from processStandardResponse into createResponseMetadata so it is included in structured response outputs; type signature updated with model?: string.
apps/sim/executor/handlers/agent/agent-handler.test.ts Added model: 'mock-model' to the expected result assertion for the structured response test, correctly covering the fixed code path.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Agent Execute] --> B{responseFormat set?}
    B -- No --> C[processStandardResponse]
    B -- Yes --> D[processStructuredResponse]

    C --> E["return { content, ...createResponseMetadata }"]
    D --> F{Valid JSON?}
    F -- Yes --> G["return { ...extractedJson, ...createResponseMetadata }"]
    F -- No --> H[Fallback to processStandardResponse]

    E --> I["createResponseMetadata includes model ✓"]
    G --> I
    H --> I
Loading

Reviews (2): Last reviewed commit: "fix(agent): update test expectation for ..." | Re-trigger Greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b8251a4. Configure here.

@waleedlatif1 waleedlatif1 merged commit 3efbd1d into staging Apr 10, 2026
12 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/fix-custom-response-model branch April 10, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant