Skip to content

feat(closes OPEN-9557): extend promote to resolve fields from function outputs#621

Open
viniciusdsmello wants to merge 1 commit intomainfrom
vini/open-9557-add-promote-parameter-to-the-trace-decorator
Open

feat(closes OPEN-9557): extend promote to resolve fields from function outputs#621
viniciusdsmello wants to merge 1 commit intomainfrom
vini/open-9557-add-promote-parameter-to-the-trace-decorator

Conversation

@viniciusdsmello
Copy link
Contributor

Summary

  • Extends the promote parameter on @trace() / @trace_async() to resolve keys from function outputs (dict, Pydantic model, or dataclass), not just inputs
  • Keys are resolved from inputs first; unresolved keys fall back to output field extraction
  • Fixes context loss bug in sync generator ASGI path by running promote inside captured_context.run()
  • Adds 10 new tests and an example demonstrating all supported output types and nested traces

Closes OPEN-9557

How it works

@tracer.trace(
    promote={
        "user_query": "agent_input_query",       # resolved from input
        "tool_call_count": "agent_tool_calls",   # resolved from output
        "tool_names": "agent_tools",             # resolved from output
    }
)
def run_agent(user_query: str) -> AgentResult:
    ...

Promoted fields become top-level columns in the trace data, enabling Openlayer tests against child step data (e.g. agent_tool_calls < 10).

Test plan

  • Promote from dict output
  • Promote from Pydantic model output
  • Promote from dataclass output
  • Mixed input + output promotion
  • List form (no aliasing) and dict form (with aliasing)
  • Nested @trace() calls — child promotes to parent trace
  • Async function promotion
  • Missing key warning (key in neither inputs nor outputs)
  • None output safety
  • Existing promote-input-only tests pass (regression)

🤖 Generated with Claude Code

Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit in Settings → Usage.

Once credits are available, reopen this pull request to trigger a review.

@viniciusdsmello viniciusdsmello changed the title feat: extend promote to resolve fields from function outputs feat(closes OPEN-9557): extend promote to resolve fields from function outputs Mar 25, 2026
…n outputs

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@viniciusdsmello viniciusdsmello force-pushed the vini/open-9557-add-promote-parameter-to-the-trace-decorator branch from 293b5e8 to eff4bed Compare March 25, 2026 18:55
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