Skip to content

tests: harness tests for compaction - #4085

Merged
Pratham-Mishra04 merged 1 commit into
devfrom
06-05-tests_harness_tests_for_compaction
Jun 5, 2026
Merged

tests: harness tests for compaction#4085
Pratham-Mishra04 merged 1 commit into
devfrom
06-05-tests_harness_tests_for_compaction

Conversation

@TejasGhatte

@TejasGhatte TejasGhatte commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

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
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • 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.

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
  • 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
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

Summary by CodeRabbit

  • Tests
    • Added end-to-end "Context Compaction cross-cut" smoke tests validating response compaction behavior: non-empty response.compaction.output, final item type "compaction" with encrypted content, and numeric usage.input_tokens.
    • Coverage added for native, OpenAI, Azure, xAI compaction endpoints and an instructions-including compaction run.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: dd3d98ab-f206-4e80-b1ef-8f683e303d38

📥 Commits

Reviewing files that changed from the base of the PR and between 6656bf0 and abf8aa5.

📒 Files selected for processing (1)
  • tests/e2e/api/collections/provider-harness.json

📝 Walkthrough

Walkthrough

Adds a new Postman collection subsection "Context Compaction cross-cut" with multiple E2E smoke tests that POST multi-turn inputs to /v1/responses/compact and provider variants, asserting the presence and shape of response.compaction, output items (last item type: "compaction" with non-empty encrypted_content), and numeric usage.input_tokens.

Changes

Context Compaction cross-cut

Layer / File(s) Summary
E2E compaction tests
tests/e2e/api/collections/provider-harness.json
Adds Postman collection items that POST multi-turn input (and one with instructions) to /v1/responses/compact, /openai/v1/responses/compact (including Azure model formatting), and xai/grok-4.3, asserting object === "response.compaction", non-empty output, last output item type: "compaction" with non-empty encrypted_content, and presence of usage.input_tokens.

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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • maximhq/bifrost#4081: Tests exercise the same compaction endpoints and response schema validated in that PR.
  • maximhq/bifrost#3457: Related updates to provider-harness filtering and cross-cut handling used by the new tests.

Suggested reviewers

  • akshaydeo
  • danpiths

Poem

I'm a rabbit in tests, nibbling JSON bright,
I hop to /responses/compact by moonlight,
I peek at the output where compactions hide,
encrypted content snug, usage numbers beside,
Hooray for green runs and a tidy test flight 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely describes the main change: adding harness tests for the compaction feature.
Description check ✅ Passed The pull request description is well-structured, following the repository template with all key sections completed including summary, changes, type of change, affected areas, testing instructions, and security considerations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 06-05-tests_harness_tests_for_compaction

Comment @coderabbitai help to get the list of available commands and usage tips.

@CLAassistant

CLAassistant commented Jun 5, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

TejasGhatte commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator Author

This was referenced Jun 5, 2026
@TejasGhatte
TejasGhatte marked this pull request as ready for review June 5, 2026 11:41
@greptile-apps

greptile-apps Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

Safe 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

Filename Overview
tests/e2e/api/collections/provider-harness.json Adds five compaction test cases to the harness; the global collection-level 'Response has content' assertion will fail for all of them (compaction shape not recognised), and the xAI test omits its Authorization header — both pre-existing flags in review threads.

Reviews (2): Last reviewed commit: "tests: harness tests for compaction" | Re-trigger Greptile

Comment thread tests/e2e/api/collections/provider-harness.json
Comment thread tests/e2e/api/collections/provider-harness.json

Pratham-Mishra04 commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Merge activity

  • Jun 5, 1:36 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 5, 1:45 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 5, 1:47 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 5, 1:47 PM UTC: @Pratham-Mishra04 merged this pull request with Graphite.

@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from 06-05-docs_compaction_api to graphite-base/4085 June 5, 2026 13:41
@Pratham-Mishra04
Pratham-Mishra04 changed the base branch from graphite-base/4085 to dev June 5, 2026 13:43
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-05-tests_harness_tests_for_compaction branch from 985a36b to 6656bf0 Compare June 5, 2026 13:44
@Pratham-Mishra04
Pratham-Mishra04 force-pushed the 06-05-tests_harness_tests_for_compaction branch from 6656bf0 to abf8aa5 Compare June 5, 2026 13:46
@Pratham-Mishra04
Pratham-Mishra04 merged commit 299f911 into dev Jun 5, 2026
13 of 14 checks passed
@Pratham-Mishra04
Pratham-Mishra04 deleted the 06-05-tests_harness_tests_for_compaction branch June 5, 2026 13:47
akshaydeo pushed a commit that referenced this pull request Jun 7, 2026
## 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 -->
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.

3 participants