sap-aicore 0.3.1 refused two top-level Messages fields that real agents send:
- `metadata` (omp sends `metadata.user_id` on every request): now accepted and
dropped in `bedrockBody`, the one builder both /invoke and
/invoke-with-response-stream use, so it never reaches Bedrock.
- `context_management` (omp and Claude Code with thinking on send
`{"edits":[{"type":"clear_thinking_20251015","keep":"all"}]}`), with
`anthropic_beta`: both are accepted as opaque native fields and forwarded
unchanged. When `context_management` comes without `anthropic_beta`, the body
gets `anthropic_beta:["context-management-2025-06-27"]`, which SAP/Bedrock
needs (without it SAP answers 400 "Extra inputs are not permitted"). An
explicit `anthropic_beta` (including [] or null) is sent as given. SAP judges
unknown edits and betas; its 400 surfaces once, redacted, with no retry. The
author verified the literal directive against live SAP deployments (Opus 4.8,
Opus 4.6, Sonnet 4.6, whole replies and streaming). Closes#864.
The test for #812 ("late failure does not delete a newer candidate") now waits
for the first token fetch to start instead of a 10ms sleep, and checks r1
failed, r2 succeeded and two fetches ran. Closes#812.
Version 0.3.1 -> 0.3.2 (the dist branch has 0.3.1; the package is not on npm).
Run at 76e1bfef2 (base 966cf717; origin/main 46fef953 has no sap-aicore change
since), on mote, HOME and TMPDIR under ~/runs, Bun 1.4.2:
- bun test packages/sap-aicore: 343 pass, 0 fail
- bun scripts/check.mjs sap-aicore: registry.json and sap-aicore ok
- bun test (repo root): 6895 tests, 6875 pass, 0 fail, 20 skip (HOME under TMPDIR; not through mote's suite lock, whose queue was hours long)
Broken by hand (messages.test.js + messages-stream.test.js, 46 tests):
- default beta line removed: 4 red (both agent-thinking tests, both defaulting tests)
- beta always set, overriding an explicit one: 4 red (override and novel-beta tests)
- context_management/anthropic_beta out of ALLOWED: 7 red
- main's messages.js: 9 red (adds both metadata tests)
The #812 test is unchanged since 19cabed44, where a 30ms delay injected in
authorize turned the old test red and the new one green.
Co-authored-by: Kanyin Cai <kanyin.cai@sap.com>