Skip to content

fix(maf): preserve captured tool-call pairing - #6799

Merged
ZaynJarvis merged 2 commits into
volcengine:mainfrom
ehz0ah:fix/maf-tool-call-pairing
Oct 30, 2026
Merged

ZaynJarvis merged 2 commits into
volcengine:mainfrom
ehz0ah:fix/maf-tool-call-pairing

Conversation

@ehz0ah

@ehz0ah ehz0ah commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fix incorrect tool arguments and names in captured Microsoft Agent Framework conversations when a provider reuses tool-call IDs.

Before: weather(Paris) -> result -> weather(Tokyo) -> result, with both calls named call_0, records the Paris result with Tokyo's arguments. _messages() builds a global last-call-wins map before converting the transcript.

After: results settle preceding calls in transcript order, using MAF occurrence IDs when available to distinguish parallel or out-of-order results. Calls without an occurrence ID remain eligible when MAF supplies one only on the result. Duplicate results retain completed-call metadata without consuming another pending call. Conflicting explicit occurrence IDs remain unpaired instead of borrowing unrelated arguments. Replayed message IDs are processed once; already acknowledged history can still provide pairing metadata without being uploaded again. Tool execution itself is unchanged.

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

Capture-correctness follow-up to #5578. No matching existing issue or PR was found.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • Replace the global call lookup with transcript-local pending calls. Preserve zero-argument calls and repeated invocations instead of deduplicating tool IDs.
  • Preserve metadata for repeated results, including replay after session restoration. A result ID synthesized for a legacy call can be reused by a new invocation; it is not treated as a unique occurrence ID.
  • Strengthen existing real-agent contracts for sequential/parallel calls, reused/distinct IDs, native compaction, streaming, and all three commit policies. Verify compaction removes tool evidence from later model requests while capture retains the original arguments and outputs.
  • Extend restart and partial-write contracts to restore serialized session state into a fresh provider, preserve acknowledged progress, and avoid replaying accepted batches. The real-SDK HTTP contract now exercises reused IDs too.

Only the adapter and its existing test file change. Public APIs, dependency bounds, stored field names, recall timing and commit policies are unchanged. No server or framework modifications are required.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows
Python MAF core OV SDK Package contracts Supplementary local probes
3.10 1.20.0 0.1.13 184 passed 34 passed
3.12 1.21.0 0.1.17 184 passed 34 passed
3.12 1.22.0 0.1.17 184 passed 34 passed
3.12 1.23.0 0.1.17 184 passed 34 passed
3.12 MAF main 1a6300e2 0.1.17 184 passed 34 passed
  • Run against the unchanged base adapter, the updated package contracts produce 66 failures / 118 passes. The failures cover reused-ID corruption, missing occurrence IDs, repeated results and orphan results through the agent lifecycle and SDK request serialization.
  • The 56 new history contracts run in streaming/non-streaming modes and with fresh/restored providers. Against the previously reviewed PR head 5dbfd14d, 48 fail / 8 pass on both minimum and current dependencies; all 56 pass after these fixes.
  • 30 fresh-process recovery scenarios pass: five dependency lanes × streaming/non-streaming × three commit policies. Each starts with 100 acknowledged records and a failed suffix, persists session state, resumes in a second process, then runs another tool interaction. The fixture ends with 110 unique records and correctly paired results. These use the real SDK against a disk-backed HTTP fixture, not a deployed server.
  • Supplementary probes cover identical polling calls, IDs reused across user turns, out-of-order occurrence IDs, orphan results, duplicate replay and native tool-result/summarization compaction. Temporary probes stay outside the package's shipped tests.
  • Ruff lint/format, mypy on minimum/current dependencies, build and Twine checks pass. Wheel runtime files match source. A clean wheel install outside the checkout passes all 184 contracts from the unpacked sdist; uv pip check passes.

Package validation commands:

# From integrations/frameworks/microsoft-agent-framework, in each dependency environment:
python -m pytest -q --confcutdir=tests tests
ruff check .
ruff format --check .
mypy src
python -m build
python -m twine check dist/*

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Documentation changes are unnecessary: this restores the existing tool-capture contract and introduces no configuration or API changes.

Screenshots (if applicable)

Not applicable.

Additional Notes

Validation is offline, with deterministic model responses and controlled SDK HTTP fixtures. No live model or deployed OpenViking run was performed. The existing MAF experimental-loop warning and pytest-asyncio fixture-scope deprecation are also present on the base.

Signed-off-by: Hao Zhe <haozhe4547@gmail.com>
Signed-off-by: Hao Zhe <haozhe4547@gmail.com>

@ZaynJarvis ZaynJarvis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Re-reviewed c91f026: both prior findings fixed, 184 tests pass on latest and minimum bounds, CI green.

@ZaynJarvis
ZaynJarvis merged commit f8524e9 into volcengine:main Oct 30, 2026
20 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants