Skip to content

[framework, docs] feat: forward TaskResult.extra_info metadata - #144

Open
qiangyupei wants to merge 1 commit into
verl-project:mainfrom
qiangyupei:pr/task-extra-info
Open

[framework, docs] feat: forward TaskResult.extra_info metadata#144
qiangyupei wants to merge 1 commit into
verl-project:mainfrom
qiangyupei:pr/task-extra-info

Conversation

@qiangyupei

Copy link
Copy Markdown
Contributor

Summary

Forward compact, use-case-specific TaskResult.extra_info fields through the generic Task Runner into a Gateway session's reward_info. This lets verifier metrics reach finalized trajectory metadata without adding task knowledge to
Gateway or the Agent Framework.

TaskResult.extra_info already exists. This PR only defines how the generic Runner forwards it when the existing report_reward=true option is enabled.

Changes

  • Merge JSON-serializable extra_info into session reward_info.
  • Keep reward, acc, and finished reserved for canonical TaskResult fields; ignore colliding metadata keys.
  • Omit all non-reserved metadata, with a warning, when it is not JSON serializable or exceeds 64 KiB after UTF-8 serialization. Canonical fields remain in the reward payload.
  • Document the contract in Task and Reward, with a short link from the Gateway documentation.
  • Add CPU tests for forwarding, reserved keys, invalid JSON, recursion, and the serialized-size boundary.

API

return TaskResult(
    reward=score,
    accuracy=pass_rate,
    finished=agent_result.finished,
    extra_info={
        "compile_ok": compile_ok,
        "passed_cases": passed_cases,
        "latency_ms": latency_ms,
    },
)

The 64 KiB limit is a Task Runner policy, not a Gateway, HTTP, Ray, or trajectory schema requirement. Session metadata is copied into finalized trajectories and training records, so large logs, source code, and evaluator artifacts should use artifact storage instead.

Compatibility

  • report_reward=false preserves the original Runner behavior and does not forward extra_info.
  • With report_reward=true and no extra_info, the canonical payload is unchanged.
  • Invalid, colliding, or oversized metadata cannot replace or remove canonical reward fields.

Validation

Validated on Ubuntu with Python 3.11 against 28174fdab3787d307ae3a96d32d3737b600575a0.

python -m pytest -q \
  tests/uni_agent/framework/test_task_runner.py \
  tests/uni_agent/tasks/test_inference_task_routing.py

# 21 passed, 3 warnings in 9.89s

The focused tests cover successful metadata forwarding, reserved-key protection, invalid JSON values, serialization failures, and the 64 KiB serialized-size boundary. Existing Task Runner and Task routing behavior is also covered by the same test run.

Focused lint and format validation:

python -m ruff check \
  uni_agent/framework/task_runner.py \
  tests/uni_agent/framework/test_task_runner.py

python -m ruff format --check \
  uni_agent/framework/task_runner.py \
  tests/uni_agent/framework/test_task_runner.py

The focused CPU tests, Ruff check, and format check passed. The three warnings come from third-party OpenTelemetry, SciPy/NumPy, and Ray dependencies and do not affect the test result.

Checklist

  • The PR is focused and explains why no issue is needed.
  • The title follows the repository format and names the owning layers.
  • Tests cover metadata forwarding, reserved-key protection, invalid values,
    serialization failures, and the serialized-size boundary.
  • Existing behavior without TaskResult.extra_info remains covered.
  • The metadata contract, compatibility behavior, and size-limit rationale
    are documented.
  • Logs, fixtures, and examples contain no credentials or private data.
  • The focused CPU tests pass (21 passed).
  • The focused Ruff check and format check pass.

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