Skip to content

Use the appended position for WorkflowTaskAdded.task_index - #135

Open
rioyu123 wants to merge 1 commit into
openai:mainfrom
rioyu123:fix/workflow-appended-task-index-20261003
Open

rioyu123 wants to merge 1 commit into
openai:mainfrom
rioyu123:fix/workflow-appended-task-index-20261003

Conversation

@rioyu123

@rioyu123 rioyu123 commented Oct 3, 2026

Copy link
Copy Markdown

Summary

When a workflow task is appended, AgentContext.add_workflow_task and the reasoning-summary done handler in stream_agent_response compute task_index with workflow.tasks.index(task). Tasks are Pydantic models compared by value, so a task equal to an earlier one gets the earlier task's index. The second task is stored at position 1, but its WorkflowTaskAdded event says task_index=0.

Use len(tasks) - 1 immediately after the append, which is where the task was actually stored. Indices for distinct tasks are unchanged.

Tests

  • Added coverage for both the queued custom-task event and the emitted reasoning-summary event, with equal-task cases and distinct-task controls.
  • All four cases pass with the fix. On the base commit, the two equal-task cases fail and the controls pass.
  • Full suite: 134 tests passed.
  • Ruff check, changed-file formatting and Pyright pass.
  • mypy . stops at the same duplicate-module discovery error for tests/_types.py on both base and this branch; no Mypy pass is claimed.

Scope

This fixes the index in the emitted WorkflowTaskAdded event. No browser or live model API run was performed. Index lookups for task updates are unchanged.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant