fix(ai-path): connect() onProgress no longer fires 'log' duplicates#32
Open
Sentinel-Bluebuilder wants to merge 1 commit into
Open
fix(ai-path): connect() onProgress no longer fires 'log' duplicates#32Sentinel-Bluebuilder wants to merge 1 commit into
Sentinel-Bluebuilder wants to merge 1 commit into
Conversation
Previously connect({ onProgress }) received both the structured stage
events (wallet, node-check, validate, session, handshake, tunnel, verify)
AND a sibling 'log' event for the same line, fired from the SDK's internal
raw log forwarder. Consumers had to filter `stage === 'log'` to avoid
triple-printing every line.
The forwarder now routes raw logs to a separate `onLog` callback. The
documented contract for `onProgress` — "one event per stage transition" —
is now what consumers actually observe.
- ai-path/connect.js: split raw `log:` forwarder; route to opts.onLog,
do NOT forward to opts.onProgress. JSDoc updated.
- ai-path/README.md: options table now lists onProgress + onLog
separately and documents `silent: true` for suppressing the SDK's
built-in step output.
- ai-path/FAILURES.md: documented the API-CONTRACT change under
Pending Integration with a migration note.
Consumer-app context: the x402 fresh-test agent harness saw triple-logged
progress lines on every connect(). After filtering 'log' on the consumer
side the output became correct — but only because both sides knew the
quirk. This fixes the SDK so the documented contract is the actual
contract.
No breaking change for consumers that ignore 'log' or set silent: true.
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
connect({ onProgress })used to fire both the structured stage event AND a sibling'log'event for the same line, forcing every consumer to filterstage === 'log'to avoid triple-printing. This PR fixes the contract soonProgressonly fires for documented stages.ai-path/connect.js: raw SDK logs now route to a newopts.onLogcallback. They are NOT forwarded toopts.onProgress. JSDoc updated to make both callbacks explicit and to list the exact stagesonProgressemits.ai-path/README.md: options table updated —onProgress,onLog, andsilent: truedocumented separately.ai-path/FAILURES.md: API-CONTRACT entry added with migration note.Why
From the x402
fresh-test/connect-from-live-docs.mjsconsumer harness: every progress line printed three times. Tracing intoai-path/connect.js:509-511showed thelog:callback fanned out toopts.onProgress('log', msg)on top of the structured stage emit. Consumer had to add:…to make output usable. The documented contract was "one event per stage transition" — this fixes the implementation to match.
Consumer-app context
The friction was discovered while building x402's agent E2E test harness. The harness drives the full connect flow from the live published
llms.txtdocs. With the duplicated events, every progress line printed three times (raw SDK log + duplicated'log'event + structured stage event). After consumer-side filtering the output became correct — but only because both ends knew the quirk. After this fix, the consumer just setssilent: trueand readsonProgresscleanly.Backward compatibility
stage === 'log'continue to work — they just never hit that branch anymore.onLog. The behavior change is "fewer events," never "missing events."connect()beyond a new optionalonLogfield.Test plan
js-sdklint/build clean (no test suite changes touched).fresh-test/connect-from-live-docs.mjs) — once linked locally to this branch, output shows one event per stage with no'log'siblings.blue-js-sdk@nextand confirm clean output without consumer-sidestage === 'log'filtering.