headroom/docs
Rod Boev 2483f57002
fix(gemini): resolve native CCR retrieval calls (#2253)
## Description

Buffered native Gemini requests currently return `headroom_retrieve`
function calls to the client because `GeminiHandlerMixin` never invokes
the shared CCR response handler. This wires native Gemini request and
response translation into the provider handler while reusing the
existing Google CCR extraction, retrieval, round-limit, mixed-tool, and
`functionResponse` machinery.

Streaming native Gemini and Gemini's OpenAI-compatible
`MALFORMED_FUNCTION_CALL` behavior remain separate surfaces.

This follows the current support boundary documented in
https://github.com/headroomlabs-ai/headroom/pull/2044.

Closes #2041

## Type of Change

- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] Documentation update
- [ ] Performance improvement
- [ ] Code refactoring (no functional changes)

## Changes Made

- Invoke `CCRResponseHandler` for successful buffered native Gemini
responses containing `headroom_retrieve`.
- Build Gemini-native continuation requests with the model
`functionCall` and matching user `functionResponse`.
- Inject the existing Google CCR function declaration while preserving
sibling Gemini tool configurations.
- Preserve mixed client-tool responses, streaming requests, non-CCR
responses, and upstream error bodies.
- Preserve Google `functionCall.id` as `functionResponse.id` through the
shared CCR identity contract.
- Leave streaming requests outside buffered CCR injection.
- Fail closed when an exclusive CCR call remains unresolved after
continuation.
- Update the CCR documentation to describe buffered native Gemini
support and the mixed-tool boundary.

## Testing

- [x] Unit tests pass (`uv run pytest tests/test_proxy_handlers_batch.py
-k "gemini_native_ccr or gemini_stream" -q`)
- [x] Linting passes (`uv run ruff check
headroom/proxy/handlers/gemini.py tests/test_proxy_handlers_batch.py`)
- [ ] Type checking passes (`uv run mypy headroom`)
- [x] New tests added for new functionality when applicable
- [ ] Manual testing performed

### Test Output

```text
Focused tests: `14 passed, 22 deselected` for `uv run pytest tests/test_proxy_handlers_batch.py -k "gemini_native_ccr or gemini_stream" -q`; `43 passed` for `uv run pytest tests/test_ccr_response_handler.py tests/test_ccr_response_handler_extra.py -q`. Scoped Ruff check and format check passed for the changed Python files. Full repository format remains blocked by pre-existing formatting outside this target.
```

## Real Behavior Proof

- Environment: Windows, Python 3.12, commit `7b3a92a8`; local
native-shape behavioral harness with no Gemini credentials.
- Exact command / steps: run the focused native Gemini handler tests,
then capture a live `generateContent` request and continuation after a
Gemini credential is available.
- Observed result: local tests prove the buffered `functionCall` to
`functionResponse` continuation, mixed-tool preservation, declaration
preservation, error forwarding, and retrieval-result shapes.
- Not tested: owner-reaching live Gemini continuation and native Gemini
streaming CCR continuation.

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes

## Additional Notes

The patch keeps Gemini wire translation in `GeminiHandlerMixin` and
extends the provider-neutral CCR identity fields for Google call ids.
Native streaming continuation and the OpenAI-compatible Gemini round-two
failure are outside this PR.

---------

Co-authored-by: JerrettDavis <mxjerrett@gmail.com>
2026-08-11 23:40:49 -05:00
..
app docs: improve discoverability for AI agents and search crawlers 2026-05-13 17:36:06 -07:00
components docs: sync Vercel docs with current code and add in-depth proxy config (#2475) 2026-07-21 16:26:56 -07:00
content/docs fix(gemini): resolve native CCR retrieval calls (#2253) 2026-08-11 23:40:49 -05:00
lib docs: sync Vercel docs with current code and add in-depth proxy config (#2475) 2026-07-21 16:26:56 -07:00
overrides fix: repair release and docs pipelines 2026-04-16 12:53:51 -05:00
screenshots Merge pull request #147 from JerrettDavis/feat/anthropic-usage-insights 2026-04-12 10:54:22 -07:00
.gitignore new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
bun.lock fix(deps): remediate dependency CVEs and publish SBOM (#1509) 2026-06-27 15:28:12 -07:00
claude-code-bedrock-headroom.md fix(bedrock): route ARNs via converse, named AWS profiles, and au. re… (#1456) 2026-07-02 22:51:05 -05:00
context-mode-integration-analysis.md perf(proxy): bound upstream calls and hot-path costs (#2852) 2026-08-09 16:24:33 -07:00
next.config.mjs new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
observability.md fix: remove rtk and lean-ctx CLI context tools (#2677) 2026-07-30 22:59:41 -07:00
package-lock.json deps: bump postcss from 8.5.19 to 8.5.26 in /docs (#2881) 2026-08-10 17:30:15 -05:00
package.json deps: bump postcss from 8.5.19 to 8.5.26 in /docs (#2881) 2026-08-10 17:30:15 -05:00
platform-feature-matrix.json fix: harden persistent install startup (#1851) 2026-07-10 00:40:34 -04:00
platform-stabilization.md fix: harden persistent install startup (#1851) 2026-07-10 00:40:34 -04:00
postcss.config.mjs new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
proxy.ts new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
README.md new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
source.config.ts docs(ci): add CI/CD flow diagrams (#1062) 2026-06-16 23:05:15 -07:00
tsconfig.json new docs UI + ts doc coverage 2026-04-12 13:15:58 +06:00
vercel.json fix: add Vercel deploy config and workflow for docs site (#1739) 2026-07-14 13:25:18 -04:00

docs

This is a Next.js application generated with Create Fumadocs.

Run development server:

npm run dev
# or
pnpm dev
# or
yarn dev

Open http://localhost:3000 with your browser to see the result.

Explore

In the project, you can see:

  • lib/source.ts: Code for content source adapter, loader() provides the interface to access your content.
  • lib/layout.shared.tsx: Shared options for layouts, optional but preferred to keep.
Route Description
app/(home) The route group for your landing page and other pages.
app/docs The documentation layout and pages.
app/api/search/route.ts The Route Handler for search.

Fumadocs MDX

A source.config.ts config file has been included, you can customise different options like frontmatter schema.

Read the Introduction for further details.

Learn More

To learn more about Next.js and Fumadocs, take a look at the following resources: