Skip to content

fix: restore clientHeaders passthrough in chatCore (regression from #1227) - #1335

Merged
diegosouzapw merged 1 commit into
diegosouzapw:release/v3.6.7from
cedrugs:fix/chatcore-missing-client-headers
Apr 16, 2026
Merged

diegosouzapw merged 1 commit into
diegosouzapw:release/v3.6.7from
cedrugs:fix/chatcore-missing-client-headers

Conversation

@cedrugs

@cedrugs cedrugs commented Apr 16, 2026 •

Copy link
Copy Markdown
Contributor
  • fix: restore clientHeaders passthrough at both executor.execute() callsites in chatCore
  • fix: re-enable x-initiator forwarding to GitHub Copilot that was lost during v3.6.5-v3.6.7 release merges

Summary

  • PR fix: forward client x-initiator header to GitHub Copilot upstream #1227 added the full x-initiator forwarding pipeline: clientHeaders field in ExecuteInput (base.ts), stash/read/cleanup in GithubExecutor (github.ts), and passthrough in chatCore.ts. All three parts were merged.
  • During the v3.6.5-v3.6.7 release branch merges, the two chatCore.ts lines that pass clientHeaders: clientRawRequest?.headers ?? null to executor.execute() were lost. The base.ts and github.ts changes survived.
  • This means the executor reads clientHeaders but never receives them - so x-initiator always falls back to "user", burning premium requests on every turn instead of only user-initiated ones.
  • This PR restores those two missing lines at the primary and retry executor.execute() callsites.

Related Issues

Validation

  • npm run lint - 0 errors (78 pre-existing warnings, none from this change)
  • npm run test:unit - 3054/3061 pass, 3 pre-existing failures (chatcore-sanitization, proxy-fetch, xiaomi-mimo - all unrelated), 4 skipped
  • End-to-end verified on a production OmniRoute instance: server logs confirm correct agent/user classification matching the client-side x-initiator header

Tests Added Or Updated

  • No new tests. This is a 2-line regression fix restoring fields that were already passing through. The existing chatCore and GitHub executor tests cover these code paths.

Reviewer Notes

  • 2-line change: only open-sse/handlers/chatCore.ts is modified - adding clientHeaders: clientRawRequest?.headers ?? null at lines ~1566 and ~1767
  • No new dependencies added
  • Backward compatible: when clients don't send x-initiator, behaviour is identical to before - "user" is sent

- restore clientHeaders passthrough lost during v3.6.5-v3.6.7 release merges
- re-enables x-initiator forwarding to GitHub Copilot (regression from PR diegosouzapw#1227)
@cedrugs
cedrugs requested a review from diegosouzapw as a code owner April 16, 2026 15:11
@cedrugs
cedrugs marked this pull request as draft April 16, 2026 15:12
@cedrugs cedrugs changed the title fix: forward client x-initiator header to GitHub Copilot upstream fix: restore clientHeaders passthrough in chatCore (regression from #1227) Apr 16, 2026
@cedrugs
cedrugs marked this pull request as ready for review April 16, 2026 15:14

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the handleChatCore function in open-sse/handlers/chatCore.ts to pass client headers to the execution and retry logic. Review feedback highlights a potential type mismatch where clientRawRequest.headers might be a Headers object instead of the expected plain object, suggesting the use of Object.fromEntries to ensure type safety and correct behavior.

log,
extendedContext,
upstreamExtraHeaders: buildUpstreamHeadersForExecute(modelToCall),
clientHeaders: clientRawRequest?.headers ?? null,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There's a potential type mismatch here. The ExecuteInput.clientHeaders property is typed as Record<string, string> | null, but clientRawRequest.headers can be a Headers object, which is not directly assignable. This could lead to issues in the executor if it expects a plain object.

To ensure type safety and correct behavior, it's better to explicitly convert a Headers object to a plain object before passing it.

Suggested change
clientHeaders: clientRawRequest?.headers ?? null,
clientHeaders: clientRawRequest?.headers instanceof Headers ? Object.fromEntries(clientRawRequest.headers) : (clientRawRequest?.headers ?? null),

log,
extendedContext,
upstreamExtraHeaders: buildUpstreamHeadersForExecute(retryModelId),
clientHeaders: clientRawRequest?.headers ?? null,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

There's a potential type mismatch here. The ExecuteInput.clientHeaders property is typed as Record<string, string> | null, but clientRawRequest.headers can be a Headers object, which is not directly assignable. This could lead to issues in the executor if it expects a plain object.

To ensure type safety and correct behavior, it's better to explicitly convert a Headers object to a plain object before passing it.

Suggested change
clientHeaders: clientRawRequest?.headers ?? null,
clientHeaders: clientRawRequest?.headers instanceof Headers ? Object.fromEntries(clientRawRequest.headers) : (clientRawRequest?.headers ?? null),

@cedrugs
cedrugs changed the base branch from main to release/v3.6.7 April 16, 2026 15:17
@diegosouzapw
diegosouzapw merged commit bf04aa3 into diegosouzapw:release/v3.6.7 Apr 16, 2026
2 checks passed
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
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.

2 participants