mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
In sessions created by `createAgentSession`, compaction, branch summaries and bug-report summaries resolved the stored OAuth credential in `AgentSession._getSummarizationRequestAuth`, then passed the access token on as `options.apiKey`. The SDK's stream function calls `modelRuntime.streamSimple`, which resolves auth again. Because it was given an explicit `apiKey`, `resolveProviderAuth` took the API-key override branch instead of using stored OAuth. Built-in providers accept the token either way. A provider whose API-key path differs from its OAuth path, such as one that refuses explicit keys, failed every summary while normal prompts worked. `createAgentSession` now marks its stream function with `markRuntimeStreamFunction`. This records it in a module-level `WeakMap` keyed by the function, mapped to its `ModelRuntime`. `_getSummarizationRequestAuth` skips pre-resolution when the agent's stream function is marked for the session's own runtime, so that runtime resolves auth once, as it does for normal prompts. The check runs after virtual-model routing. Bare `streamSimple` and custom `streamFn`s still receive resolved credentials, so the fixes for #6324 and #7579 are unchanged. If a caller replaces `agent.streamFunction`, the old behavior applies. **Testing** - Added `test/suite/regressions/11520-sdk-summary-oauth-auth.test.ts`. It builds an SDK session on a provider that has stored OAuth and also an API-key method, runs a branch summary, and asserts two things: no `getAuth` call carries an `apiKey` override, and the provider receives the OAuth access token. It fails without the change and passes with it. - `npm run check` passes and `./test.sh` passes. I also ran the related tests: 6324 branch-summary auth, compaction model overrides, auto-compaction cancellation, SDK stream options, virtual models, and the compaction and branch-summary tests. - Manual reproduction: an SDK script with an `openai` OAuth credential that logs `ModelRuntime.getAuth` during `navigateTree(..., { summarize: true })`. Before the change there were two calls, the second with `apiKey = <oauth token>`. After the change there is one call, with no override. Fixes #11520 Requested by @badlogic Co-authored-by: triagent <triagent@localhost> |
||
|---|---|---|
| .. | ||
| 1717-2113-agent-session-event-settlement.test.ts | ||
| 2023-queued-slash-command-followup.test.ts | ||
| 2753-reload-stale-resource-settings.test.ts | ||
| 2781-skill-collision-precedence.test.ts | ||
| 2791-fswatch-error-crash.test.ts | ||
| 2835-tools-allowlist-filters-extension-tools.test.ts | ||
| 2860-replaced-session-context.test.ts | ||
| 3217-scoped-model-order.test.ts | ||
| 3302-find-path-glob.test.ts | ||
| 3303-find-nested-gitignore.test.ts | ||
| 3317-network-connection-lost-retry.test.ts | ||
| 3592-no-builtin-tools-keeps-extension-tools.test.ts | ||
| 3616-settings-inmemory-reload.test.ts | ||
| 3686-session-name-event.test.ts | ||
| 3688-tree-cancel-compacting.test.ts | ||
| 3982-message-end-cost-override.test.ts | ||
| 4167-thinking-toggle-pending-tool-render.test.ts | ||
| 5080-signal-shutdown-extension-cleanup.test.ts | ||
| 5109-exclude-tools.test.ts | ||
| 5208-late-bash-output.test.ts | ||
| 5217-compaction-reason.test.ts | ||
| 5303-bash-output-truncation.test.ts | ||
| 5433-extension-oauth-prompt-input.test.ts | ||
| 5596-missing-theme-export.test.ts | ||
| 5661-uppercase-header-values.test.ts | ||
| 5724-sigterm-signal-exit.test.ts | ||
| 5868-rpc-unknown-command-id.test.ts | ||
| 5943-session-start-notify.test.ts | ||
| 5996-session-name-newlines.test.ts | ||
| 5998-blocked-tool-terminate.test.ts | ||
| 6019-explicit-provider-retry-message.test.ts | ||
| 6104-find-root-relativization.test.ts | ||
| 6162-extension-active-tools-next-turn.test.ts | ||
| 6260-inline-extension-naming.test.ts | ||
| 6324-branch-summary-ambient-auth.test.ts | ||
| 6363-agent-settled-event.test.ts | ||
| 6596-taskkill-enoent.test.ts | ||
| 6647-compaction-retries-transient-stream-drop.test.ts | ||
| 6768-copilot-compaction-base-url.test.ts | ||
| 6904-dns-transport-retry.test.ts | ||
| 6949-unavailable-scoped-model.test.ts | ||
| 6999-models-json-hot-reload.test.ts | ||
| 7027-credential-refresh-hang.test.ts | ||
| 7048-compaction-truncated-summary.test.ts | ||
| 7150-rpc-prompt-during-compaction.test.ts | ||
| 7153-scoped-models-refresh.test.ts | ||
| 7187-malformed-package-manifest.test.ts | ||
| 7193-event-bus-lifecycle.test.ts | ||
| 7209-model-selector-filter-resets-selection.test.ts | ||
| 7253-manual-compact-during-response.test.ts | ||
| 7269-cli-end-of-options.test.ts | ||
| 7290-json-stream-linear.test.ts | ||
| 7301-stalled-availability-refresh.test.ts | ||
| 7443-model-command-cached-match.test.ts | ||
| 7497-session-discovery-symlink.test.ts | ||
| 7572-provider-retry-settings-merge.test.ts | ||
| 7731-tui-method-wrapping.test.ts | ||
| 7829-invalid-settings-warning.test.ts | ||
| 7911-json-stream-usage.test.ts | ||
| 7925-toolcall-start-metadata.test.ts | ||
| 8237-node-sea-extension-loading.test.ts | ||
| 8261-subagent-project-trust.test.ts | ||
| 8328-zero-usage-auto-compaction.test.ts | ||
| 8337-utf8-bom-parsing.test.ts | ||
| 8423-extension-factory-failure.test.ts | ||
| 8537-custom-message-tool-result-ordering.test.ts | ||
| 8611-thinking-toggle-pending-bash-output.test.ts | ||
| 8724-in-memory-fork-active-tool.test.ts | ||
| 8935-parallel-preflight-abort.test.ts | ||
| 8964-extension-provider-streaming.test.ts | ||
| 8989-fork-compaction-label-boundary.test.ts | ||
| 9068-user-bash-fail-closed.test.ts | ||
| 9178-tree-during-compaction.test.ts | ||
| 9340-9777-auto-compaction-cancellation.test.ts | ||
| 9540-extension-loader-lazy.test.ts | ||
| 9789-context-handler-system-messages.test.ts | ||
| 10285-mcp-tool-renderers.test.ts | ||
| 11156-pi-ai-models-virtual-module.test.ts | ||
| 11227-recovery-omits-tool-results.test.ts | ||
| 11520-sdk-summary-oauth-auth.test.ts | ||
| copilot-request-size-overflow.test.ts | ||
| extension-factory-cache.test.ts | ||
| pre-prompt-compaction-no-continue.test.ts | ||
| startup-session-rebind-duplicate-subscription.test.ts | ||
| tree-during-streaming.test.ts | ||