Skip to content

Add x-session-affinity header for Fireworks AI prompt caching#23451

Open
richardanaya wants to merge 2 commits intoanomalyco:devfrom
richardanaya:dev
Open

Add x-session-affinity header for Fireworks AI prompt caching#23451
richardanaya wants to merge 2 commits intoanomalyco:devfrom
richardanaya:dev

Conversation

@richardanaya
Copy link
Copy Markdown

@richardanaya richardanaya commented Apr 19, 2026

Fireworks AI uses per-replica in-memory caching that requires session affinity via the x-session-affinity HTTP header. Without this header, requests are routed to random replicas, causing cache misses even when the same session is reused.

This fix adds the x-session-affinity header for all Fireworks AI requests, using either a provided sessionId or a generated session identifier.

See: https://docs.fireworks.ai/guides/prompt-caching

Issue for this PR

Closes #23450

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds cacheing hints as per their documentation

If you paste a large clearly AI generated description here your PR may be IGNORED or CLOSED!

How did you verify your code works?

Tested that opencode could still run with bun dev against fireworks.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

If you do not follow this template your PR will be automatically rejected.

@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title Add x-session-affinity header for Fireworks AI prompt caching doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 19, 2026
@richardanaya richardanaya force-pushed the dev branch 3 times, most recently from 465d9c2 to 7d77c3c Compare April 19, 2026 22:46
Fireworks AI uses per-replica in-memory caching that requires session affinity
via the x-session-affinity HTTP header. Without this header, requests are
routed to random replicas, causing cache misses even when the same session
is reused.

This fix adds the x-session-affinity header for Fireworks AI requests when
a valid sessionId is provided in options.

See: https://docs.fireworks.ai/guides/prompt-caching
@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@rekram1-node
Copy link
Copy Markdown
Collaborator

Opencode already sends this header by default for all providers

@rekram1-node
Copy link
Copy Markdown
Collaborator

"x-session-affinity": input.sessionID,

@rekram1-node
Copy link
Copy Markdown
Collaborator

I just ran through http proxy, it is being sent through as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: fireworks AI needs cache key header for more consistent cacheing

2 participants