Repository navigation
test: add opt-in live tests against the Anthropic API and gateways - #258
Merged
Merged
Conversation
2 of 3 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
hakula139
force-pushed
the
test/live-gateway
branch
from
October 16, 2026 09:58
56d92d8 to
a309175
Compare
Mock-server tests cannot show that a real endpoint streams, caches, replays signed thinking, and accepts the billing header. tests/live.rs runs ox headless and in the bare REPL against whatever endpoint the environment selects, and checks the session file it writes: - streamed text matches the recorded reply - a tool round trip reads the first request from the prompt cache - signed thinking after tool results is replayed across three turns - auto-compaction summarizes from the cached conversation and shrinks the next prompt - --continue answers from the resumed transcript and cache The tests are #[ignore]d and also return early unless OX_LIVE=1, so CI and --include-ignored send no requests. Each runs with a scratch home, config, data, and state directory, so no global instructions, config file, or stored login apply, and drops inherited OX_* behavior settings. After each run, the harness fails the test when a credential or a custom header value appears in the captured output or any file the run wrote, naming the variable without printing the value. The testing conventions gain a Live Tests section with a checklist for the TUI-only paths, and the API research note records the billing header recheck against Claude Code 2.1.301.
hakula139
force-pushed
the
test/live-gateway
branch
from
October 16, 2026 13:48
a309175 to
2a22e93
Compare
hakula139
enabled auto-merge (squash)
October 16, 2026 14:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The runtime features that depend on a real endpoint had no repeatable check, including streaming, prompt caching, signed thinking replay, compaction, resume, and the billing header. This adds opt-in live tests that run
oxagainst whatever endpoint the environment selects, plus a checklist for the TUI-only paths. Both were run against the Anthropic API and an Anthropic-compatible gateway, and the per-feature results are in the comment on #123.crates/oxide-code/tests/live.rsrunsoxheadless and in the bare REPL, then checks the session file it writes:--continueanswers from the resumed transcript and reads its cache.#[ignore]d and also return early unlessOX_LIVE=1, so CI and--include-ignoredsend no requests. Each runs with a scratch home, config, data, and state directory, so no global instructions, config file, or stored login apply, and the endpoint and credentials come from the environment alone. The harness drops inheritedOX_*settings other thanOX_EXTRA_CA_CERTS, along withANTHROPIC_EFFORTandANTHROPIC_MAX_TOKENS.OX_LIVE_MODELandOX_LIVE_THINKING_MODELpick the models.ANTHROPIC_AUTH_TOKEN,ANTHROPIC_API_KEY, orCLAUDE_CODE_OAUTH_TOKEN, or anANTHROPIC_CUSTOM_HEADERSvalue of 8 or more characters, appears in the captured stdout, stderr, or any file under the scratch directory. The failure names the source and the variable without printing the value./compact, the/modelswap, Esc cancellation, and a leak check that testsgrep's exit status. The API research note records the billing header recheck against Claude Code 2.1.301. The salt and indices match, the fingerprint's message selection changed (Fingerprint the billing header from the first user prompt #257), and a scan of the binary did not find the xxHash64 seed.The runs found four bugs, filed as #254, #255, #256, and #257. This PR leaves #123 open because the seed recheck is incomplete.
Test plan
OX_LIVE=1 cargo test --test live -- --ignoredpassed all 5 tests against the Anthropic API with an OAuth token, where requests carry the billing header with a livecch.oxon macOS rejects the gateway's certificate (Trust long-lived certificates from an extra CA on macOS #254).OX_LIVE=1, temporary probe tests confirmed that a fakeANTHROPIC_API_KEYechoed to stdout and a fake custom header value written to a scratch file each fail with the source and variable name and without the value, and that a 2-character header value is skipped.OX_LIVE=1,cargo testreports the 5 live tests as ignored, and--include-ignoredpasses them without sending requests./compactand the/modelswap in both directions passed, and the leak check found no token in the logs or session files. Esc stops the stream, but the next reply also answers the cancelled prompt (Tell the model when the user interrupted the previous prompt #256).cargo fmt --all --check,cargo build,cargo clippy --all-targets -- -D warnings,cargo test,cargo llvm-cov,pnpm format,pnpm lint,pnpm spellcheck, and the pre-commit hooks passed. Files undertests/are outside the coverage report.