tests: harness tests for compaction - #4085
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a new Postman collection subsection "Context Compaction cross-cut" with multiple E2E smoke tests that POST multi-turn inputs to ChangesContext Compaction cross-cut
Sequence Diagram(s)sequenceDiagram
participant PostmanRunner
participant BifrostAPI
participant AssertionScript
PostmanRunner->>BifrostAPI: POST /v1/responses/compact (or /openai/v1/... /xai/...)
BifrostAPI-->>PostmanRunner: response.compaction JSON with output[], usage
PostmanRunner->>AssertionScript: run assertions on response body
AssertionScript-->>PostmanRunner: pass/fail
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Confidence Score: 4/5Safe to merge once the two open issues from prior review threads are resolved; the new test cases are otherwise well-structured and isolated from production code. Two known defects from earlier review threads remain in the diff: the collection-level 'Response has content' assertion will fire and fail on every compaction response because the global shape-detection script does not handle object === 'response.compaction', and the xAI test omits the Authorization header that every other test on the same endpoint includes. Until these are fixed, all five new tests will produce failures unrelated to the feature under test. tests/e2e/api/collections/provider-harness.json — specifically the global collection-level test script (lines 29–126) and the xAI request header block. Important Files Changed
Reviews (2): Last reviewed commit: "tests: harness tests for compaction" | Re-trigger Greptile |
Merge activity
|
985a36b to
6656bf0
Compare
6656bf0 to
abf8aa5
Compare
## Summary
Adds a new "Context Compaction cross-cut" test collection to the provider harness, covering the `/v1/responses/compact` endpoint across multiple providers and routing paths.
## Changes
- Added a new Postman collection folder `Context Compaction cross-cut` containing five end-to-end test cases:
- Compaction via the native Bifrost API using `openai/gpt-4o`
- Compaction via the OpenAI-compatible route using `gpt-4o`
- Compaction via the OpenAI-compatible route using an Azure deployment
- Compaction via the native Bifrost API using `xai/grok-4.3`
- Compaction with a system `instructions` field using `gpt-4o`
- Each test validates that the response `object` equals `response.compaction`, that `output` is a non-empty array, that the last output item has `type: compaction` with a non-empty `encrypted_content` string, and that `usage.input_tokens` is present.
## Type of change
- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [x] Chore/CI
## Affected areas
- [ ] Core (Go)
- [ ] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs
## How to test
Run the provider harness collection against a running Bifrost instance using Newman or the Postman UI, ensuring the `baseUrl`, `openaiKey`, and `azureDeployment` environment variables are set.
```sh
newman run tests/e2e/api/collections/provider-harness.json \
--env-var baseUrl=<your-bifrost-url> \
--env-var openaiKey=<your-openai-key> \
--env-var azureDeployment=<your-azure-deployment>
```
Expected outcome: all five compaction tests pass with `200` responses and valid `response.compaction` objects returned.
## Breaking changes
- [ ] Yes
- [x] No
## Related issues
## Security considerations
Test requests include API keys passed via environment variables (`{{openaiKey}}`); no secrets are hardcoded in the collection.
## Checklist
- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **Tests**
* Added end-to-end test coverage for response compaction functionality across multiple API endpoints and providers, validating response structure and output formatting.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Summary
Adds a new "Context Compaction cross-cut" test collection to the provider harness, covering the
/v1/responses/compactendpoint across multiple providers and routing paths.Changes
Context Compaction cross-cutcontaining five end-to-end test cases:openai/gpt-4ogpt-4oxai/grok-4.3instructionsfield usinggpt-4oobjectequalsresponse.compaction, thatoutputis a non-empty array, that the last output item hastype: compactionwith a non-emptyencrypted_contentstring, and thatusage.input_tokensis present.Type of change
Affected areas
How to test
Run the provider harness collection against a running Bifrost instance using Newman or the Postman UI, ensuring the
baseUrl,openaiKey, andazureDeploymentenvironment variables are set.Expected outcome: all five compaction tests pass with
200responses and validresponse.compactionobjects returned.Breaking changes
Related issues
Security considerations
Test requests include API keys passed via environment variables (
{{openaiKey}}); no secrets are hardcoded in the collection.Checklist
docs/contributing/README.mdand followed the guidelinesSummary by CodeRabbit