samples: benchmark Dynamic Workflow token reduction - #177
Open
Tsuyoshi Ushio (TsuyoshiUshio) wants to merge 13 commits into
Open
samples: benchmark Dynamic Workflow token reduction#177Tsuyoshi Ushio (TsuyoshiUshio) wants to merge 13 commits into
Tsuyoshi Ushio (TsuyoshiUshio) wants to merge 13 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This reverts commit 0efa240. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 3b5a7e42-f11f-4f3f-b488-18abaee5fc76
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 22ab44a2-734f-4590-b3a1-eb24ff46f621
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 22ab44a2-734f-4590-b3a1-eb24ff46f621
Preserve the existing compact usage event and emit a separately versioned provider detail record only when explicitly enabled. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 22ab44a2-734f-4590-b3a1-eb24ff46f621
Pin the E2E worker to the current checkout and retain provider-specific usage dimensions in benchmark results. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 22ab44a2-734f-4590-b3a1-eb24ff46f621
Cover enabled streaming emission, stable/detail correlation, parser guards, and checkout isolation identified by the independent testing review. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 22ab44a2-734f-4590-b3a1-eb24ff46f621
Separate queue submission from host lifecycle so users can watch token logs and inspect report blobs directly. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 22ab44a2-734f-4590-b3a1-eb24ff46f621
Declare the Azure Storage Queue SDK used by both benchmark scripts in the sample environment. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 22ab44a2-734f-4590-b3a1-eb24ff46f621
Tsuyoshi Ushio (TsuyoshiUshio)
marked this pull request as ready for review
August 26, 2026 03:04
added 2 commits
August 28, 2026 14:53
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 22ab44a2-734f-4590-b3a1-eb24ff46f621
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 22ab44a2-734f-4590-b3a1-eb24ff46f621
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Initial E2E results (retained)
Using Foundry
gpt-5.4-miniwith 40 evidence lines per service:The canonical reports matched for every valid pair. The 20-service baseline processed only 2 of 20 services, so that pair is invalid and intentionally excluded from the reduction calculation.
This initial run used the machine's ambient editable runtime install. It remains here as the original observation, but the harness now prepends this checkout's
src/to the workerPYTHONPATHso subsequent runs cannot resolve another worktree.Detailed opt-in E2E results
After enabling
AZURE_FUNCTIONS_AGENTS_DETAILED_TOKEN_USAGE=trueand pinning the worker to this checkout, the same workload produced:All four canonical report pairs matched exactly. Input-token reduction increased from 47.3% to 91.9%, while output-token reduction ranged from 92.6% to 97.2%.
Foundry also reported
openai.cached_input_tokens:The baseline's cached input, uncached input, and output all grow with service count because evidence returns through the model's tool-calling loop. Dynamic Workflow keeps intermediate evidence in Activities, so model usage stays comparatively flat; its growth is primarily the workflow plan itself. The provider emitted no reasoning-token dimension in these trials, so none is inferred.
Repeated latency and quality results
A second run used the same Foundry
gpt-5.4-minideployment, 40 evidence lines per service, alternating execution order, and three paired repeats per workload size.report_latency_msmeasures queue submission through canonical report Blob availability; it excludes host/emulator startup and token-log validation.Measured accuracy was equivalent: Baseline and Dynamic Workflow received identical deterministic-oracle and Vally overall scores.
The independent field-level oracle scored all 24 mode outputs
1.0with exact pass. Missing, wrong, reordered, or fabricated fields reduce this score. Vally 0.14.0 then graded blinded ATIF trajectories for repeat 1 with a fixed rubric andgpt-5.4-mini: all eight Baseline/Workflow outputs scored1.0overall and passed every criterion. Three of 32 individual rubric scores were 4/5 for raw-JSON presentation; every factual score was 5/5. No quality loss was observed for this structured task, but this does not establish equivalence for open-ended tasks.The machine-readable run is committed under
samples/workflow-token-benchmark/results/2026-08-28-foundry/, including paired benchmark JSON, 24 ATIF trajectories, eight Vally JSONL verdicts, commands, environment, and limitations. Python 3.14.0 was used because the installed Python 3.13.15 Functions worker exited with Windows access violation0xC0000005during indexing; those failed startups produced no observations.Runtime telemetry
The existing
Agent token usage: {json}event is unchanged. When explicitly enabled, the runtime emits a separateAgent token usage detail: {json}event withschema_version: 1and the provider/MAF numeric dimensions. Detail normalization and logging are separately guarded so they cannot suppress the stable event. Invalid or missing provider dimensions are not estimated.The runtime change and benchmark capture are separate commits so the opt-in feature can be reverted without removing the sample. Latency/quality support and the recorded result set are also separate commits.
Validation
python -m ruff check src testspython -m mypy srcpython -m pytest --cache-clear --cov=./src/azure_functions_agents --cov-report=xml --cov-branch tests— 1,084 passedTemporary dependency
This PR temporarily includes the ExecPlan guidance commits from #174, which were used while developing the sample. Those commits will be removed from this PR before final readiness.