Skip to content

fix(trial): write target trajectory when a user agent is present - #4003

Open
gyanu2507 wants to merge 3 commits into
harbor-framework:mainfrom
gyanu2507:fix/populate-target-context-with-user-agent
Open

gyanu2507 wants to merge 3 commits into
harbor-framework:mainfrom
gyanu2507:fix/populate-target-context-with-user-agent

Conversation

@gyanu2507

@gyanu2507 gyanu2507 commented Oct 30, 2026 •

Copy link
Copy Markdown

Summary

Fixes #3971. With a simulated user agent, _populate_agent_context only ran populate_context_post_run on the user agent. Most target agents write agent/trajectory.json in that hook, so verifiers graded an empty trajectory and target token/cost accounting was skipped.

This change always runs the target agent's post-run hook on a separate AgentContext, stores non-empty target usage under agent_result.metadata["target"], and still calls the user agent's hook when the shared context is empty.

Test plan

  • PYTHONPATH=src pytest -p no:randomly tests/unit/trial/test_populate_agent_context.py (5 passed)
  • Simulated-user trial with --agent claude-code produces agent/trajectory.json after the run

Simulated-user trials previously only ran populate_context_post_run on the
user agent, so agent/trajectory.json was never written and verifiers could
grade an empty trajectory.
@vercel

vercel Bot commented Oct 30, 2026

Copy link
Copy Markdown

@gyanu2507 is attempting to deploy a commit to the Harbor Framework Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

Enjoy a better diff viewing experience by clicking one of these URLs:

devin-ai-integration[bot]

This comment was marked as resolved.

Simulated-user trials store target agent tokens under metadata["target"].
Job and viewer totals previously ignored that payload.
@gyanu2507

Copy link
Copy Markdown
Author

Included metadata["target"] token/cost fields in compute_token_cost_totals, so simulated-user trials add the target agent into job/viewer totals. Added a unit test for the mixed user+target case.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simulated-user trials never run the target agent's populate_context_post_run, so agent/trajectory.json is missing

1 participant