Skip to content

fix(runner): preserve structured tool results in events - #117

Merged
divo12 merged 1 commit into
mainfrom
fix/role-tool-structured
Aug 16, 2026
Merged

divo12 merged 1 commit into
mainfrom
fix/role-tool-structured

Conversation

@divo12

@divo12 divo12 commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

User description

Summary

  • add typed structured: Mapping[str, object] | None to RoleToolResult
  • copy ToolUseResult.structured into the observer event
  • cover default and copied payload behavior

This closes the typed observer contract required by Chorus's merged Dream adapter.

Test plan

  • uv run pytest tests/test_runner/test_role_tool_structured.py -v
  • Ruff on touched files
  • mypy on touched production files

Made with Cursor


CodeAnt-AI Description

Preserve structured tool results for downstream observers

What Changed

  • Tool result events now include structured metadata when a tool provides it
  • Structured metadata is copied before being sent to observers, preventing later changes from affecting recorded events
  • Tools without structured metadata continue to produce events with no structured payload

Impact

✅ Structured tool evidence available to downstream adapters
✅ Reliable observer event data
✅ Backward-compatible tool results without metadata

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

Carry typed tool result metadata through RunTaskObserver so downstream adapters can consume structured evidence without parsing text.

Co-authored-by: Cursor <cursoragent@cursor.com>
@codeant-ai

codeant-ai Bot commented Aug 16, 2026

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 8523bd9 Aug 16, 2026 · 15:07 15:10

@codeant-ai

codeant-ai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

divo12 has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Aug 16, 2026
Comment thread src/dream/runner/role.py
tool=ev.name,
is_error=ev.is_error,
content=ev.content,
structured=dict(ev.structured) if ev.structured is not None else None,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: The real Session translation constructs ToolUseResult without structured, and the engine's ToolExecutionCompleted event does not carry it, so this line receives None for production tool calls even when the underlying ToolResult contains structured data. Propagate the structured payload through the engine event and session translation layers before copying it here. [api mismatch]

Severity Level: Major ⚠️
- ❌ Structured payloads disappear from production role tool observers.
- ⚠️ Chorus adapters receive only textual tool-result content.
- ⚠️ Built-in structured tools lose machine-readable observer data.

Fix in Cursor Fix in VSCode Claude

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** src/dream/runner/role.py
**Line:** 249:249
**Comment:**
	*Api Mismatch: The real `Session` translation constructs `ToolUseResult` without `structured`, and the engine's `ToolExecutionCompleted` event does not carry it, so this line receives `None` for production tool calls even when the underlying `ToolResult` contains structured data. Propagate the structured payload through the engine event and session translation layers before copying it here.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@divo12
divo12 merged commit 7a65e1c into main Aug 16, 2026
4 checks passed
@divo12
divo12 deleted the fix/role-tool-structured branch August 16, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant