Rock in the bed

It always happens at the worst possible moment. The agent has finally read the right files, absorbed the constraint I explained twice, and ruled out the dead end we chased ten minutes ago. Then Codex stops mid-task: "You've hit your usage limit."
Waiting for the allowance to reset is annoying. Losing the session—everything the agent knows about why the code looks the way it does—is worse.
So I had an idea: use my Codex subscription while it lasts, then slip the conversation into Amazon Bedrock when it runs out. Hence the name. Same history, same decisions, same files on disk. Swap only the inference provider and keep going.
Pasting a summary into a fresh chat would be easy, and it would dodge the interesting question: can a live Codex conversation cross a provider boundary onto an open-weight model on AWS and carry on as if nothing happened?
Fork, don't resume #
A coding task's state lives in two places: the repository on disk and the conversation transcript in the agent's session store. The repository holds the current code; the transcript holds why the code looks that way—what I asked for, which dead ends I ruled out, and what the tests just printed.
My first assumption was that an orchestrator could simply take a paused subscription thread and resume it with a different model_provider. Codex rejects that. In its session model, a thread belongs to the provider that created it; changing providers requires forking the conversation, history included, into a new thread ID pointing at the same working directory.[1]
At the CLI level, that boils down to one command:
codex exec fork SOURCE_THREAD_ID -
The follow-up prompt arrives on stdin, and the harness passes the exact SOURCE_THREAD_ID rather than guessing "most recent session." Everything else is locked down: no user config bleed, no plugins or sub-agents, no automatic provider retries, and a local model catalog.
The full fork invocation from local/continuity.mjs
const args = [
'exec', '--ignore-user-config', '--ignore-rules', '--json',
'--sandbox', options.containerIsolation ? 'danger-full-access' : 'workspace-write',
'-C', workspace,
'-c', 'approval_policy="never"',
'-c', 'web_search="disabled"',
'-c', 'service_tier="default"',
'-c', 'features.apps=false',
'-c', 'features.plugins=false',
'-c', 'features.multi_agent=false',
'-c', `model_provider=${JSON.stringify(bedrock ? options.provider : 'openai')}`,
];
if (bedrock) {
args.push(
'-m', options.model,
'-c', `model_providers.${options.provider}.base_url=${JSON.stringify(options.baseUrl)}`,
'-c', `model_catalog_json=${JSON.stringify(join(experiment, 'local/gpt-oss-catalog.json'))}`,
'-c', 'model_reasoning_effort="low"',
'-c', 'model_reasoning_summary="none"',
'fork', threadId, '-',
);
}
Before automating anything or touching AWS compute, I started locally, so only the inference would cross the wire:
Subscription-backed Codex turn
|
| save conversation, then fork with history
v
Codex continuation -> local compatibility adapter -> Bedrock GPT-OSS-20B
|
v
The same project files and local execution tools
Endpoint archaeology on Bedrock #
The first surprise: the menu shows it, but the kitchen won't serve it.
Mantle's /v1/models happily listed closed GPT models like GPT-6 Sol and GPT-5.6 Luna. Calling them returned HTTP 401—model not available for this account—even after I double-checked credentials and IAM policies. Control calls to Amazon Nova Micro and OpenAI's open-weight openai.gpt-oss-20b succeeded. That narrowed things down immediately: not IAM, not Codex—just account-level model availability.
GPT-OSS-20B gave me a working target, and then taught me a second lesson: a 200 from Bedrock Converse is not enough. Codex speaks the OpenAI Responses API, and for openai.gpt-oss-20b, AWS serves Responses through Bedrock Mantle, not the standard Bedrock Runtime endpoint—and under /v1, not the /openai/v1 path used by other models[2]:
| Setting | Value |
|---|---|
| Region | us-east-1 |
| Endpoint | Bedrock Mantle |
| Model ID | openai.gpt-oss-20b |
| Base URL | https://bedrock-mantle.us-east-1.api.aws/v1 |
| Request path | /v1/responses |
A bare POST /v1/responses signed with SigV4 for the bedrock-mantle service came back HTTP 200 with a clean OK. Time to point Codex at it.
My first real continuation attempt died before it reached the model: the AWS profile wanted MFA again. Humbling, but at least that failure was mine. The next one wasn't.
Changing the URL is not enough #
Pointing a forked Codex thread straight at Mantle failed validation immediately.
Codex's saved rollout (its on-disk session transcript) isn't just plain user/assistant messages. It contains Codex-specific history items (additional_tools, custom_tool_call, custom_tool_call_output), transport hints (client_metadata, prompt_cache_key), and a request for OpenAI-hosted reasoning.encrypted_content. On top of that, the pinned Codex CLI (0.171.0) had no built-in metadata for openai.gpt-oss-20b.
The fix took two pieces:
- A local model catalog (
local/gpt-oss-catalog.json) declaring the 128k context window, text-only modality, direct tool mode, and supported reasoning levels. - A local HTTP adapter (
local/oss-bridge.mjs) bound to an ephemeral loopback port (127.0.0.1:0) with a per-run random bearer token. Codex talks standard Responses HTTP to localhost; the adapter translates the payload, signs it with temporary AWS credentials kept strictly in memory, and streams the server-sent events (SSE) back.
Even that took a couple of surprises to get right.
Surprise 1: HTTP 200 can still be a failure. Mantle returned 200 OK and then emitted an error inside the event stream, because previous assistant messages still carried output_text blocks that required provider-owned output IDs. Flattening those into plain input strings fixed validation—and taught me to audit every request for an actual response.completed event rather than trusting the status code.
Surprise 2: GPT-OSS couldn't edit files. Inside a Linux Docker container, the model recalled the conversation fine, then kept failing file edits. Codex exposes apply_patch as a freeform custom tool, which Mantle doesn't accept. So the bridge disguises it: outbound, apply_patch becomes an ordinary JSON function taking { input: string }; inbound, responseTranslator() turns the model's call back into Codex's native custom_tool_call:
// Inbound: convert the function call back to Codex's custom_tool_call
const convertItem = (item) => {
if (item?.type !== 'function_call' || item.name !== 'apply_patch') return item;
patchIds.add(item.id);
let input = '';
if (item.arguments) {
const args = JSON.parse(item.arguments);
if (typeof args.input !== 'string') throw new Error('Fallback apply_patch input must be a string');
input = args.input;
}
const { arguments: ignored, ...rest } = item;
return { ...rest, type: 'custom_tool_call', input };
};
While the JSON arguments stream in, the translator swallows the function_call_arguments delta frames for tracked patch IDs, so Codex receives one clean custom_tool_call with the complete patch text.
The outbound half (normalizeRequest)
// Outbound (normalizeRequest): turn Codex's custom apply_patch into a JSON function
if (tool.type === 'custom' && tool.name === 'apply_patch') {
return [{
type: 'function',
name: 'apply_patch',
description: 'Edit project files using a patch. Put the complete patch text in the input string...',
parameters: {
type: 'object',
properties: { input: { type: 'string', description: 'Complete apply_patch patch text' } },
required: ['input'],
additionalProperties: false,
},
}];
}
The memory trap #
A model that edits the right file hasn't proven anything—it could have just read the workspace and guessed the task. I needed proof that the Bedrock fork remembered the conversation. So I set a trap:
- Stage 1 (subscription): make
greet.mjstrim whitespace, sogreet(" alice ") === "Hello, alice!". The prompt also contains a random synthetic marker, with strict instructions never to write it into any file. - Pre-fork check: the harness runs stage 1's test independently and scans every file in the workspace to confirm the marker never touched disk.
- Stage 2 (Bedrock fork): keep trimming, add capitalization—
greet(" alice ") === "Hello, Alice!"—and repeat the marker from stage 1 without being given it again.
The only place that marker existed was the conversation history. If GPT-OSS-20B could say it back, the history had crossed the boundary.
It could:
{
"status": "passed",
"sourceThreadId": "01a220a5-871e-7df0-901e-782ae3685533",
"targetThreadId": "01a220f4-01e3-7ae1-89be-13b134926ab7",
"bedrockProvider": "bedrock-oss-bridge",
"memoryChallengePassed": true,
"testOutput": "stage-2 passed\n"
}
It worked locally, then again inside a read-only, non-root Docker container—where a second, replacement container loaded the persisted volume and re-passed the test with zero model calls.
One detail nagged at me, though: changing a three-line greeting function had taken 12 Bedrock requests. It passed, so I moved on. That decision came back to bite me two days later.
When is it safe to spend money? #
Manual forking proved continuity. An automatic fallback has a trickier job: deciding when it is actually safe to start paying AWS.
You do not want paid inference triggered by a network blip, a bad auth token, a failing shell command, or—worst of all—a tool output that happens to contain the words "usage limit exceeded." OpenAI also documents that an active turn can finish even after the meter reaches 100%.[3] Interrupting a turn that was about to succeed would be self-sabotage.
To get a trustworthy signal, I moved the subscription leg from codex exec onto Codex App Server (codex app-server --listen stdio://), the JSON-RPC interface IDE integrations use. It streams structured lifecycle events, including retry flags (willRetry) and machine-readable codexErrorInfo codes.[4]
The switching policy lives in handoffDecision() in local/handoff.mjs, and it is deliberately paranoid. It has eleven ways to say no and exactly one way to say yes:
| It refuses when… | Reason code |
|---|---|
| The process timed out, was killed, or the event stream is garbled | process-interrupted, invalid-event-stream |
| The events belong to a different thread, or the turn didn't cleanly fail | source-thread-mismatch, inconsistent-failure, missing-terminal-failure |
| There's no structured terminal error from App Server | missing-structured-terminal-error |
The error code is anything other than usageLimitExceeded |
other-provider-error |
| A side-effect tool failed, is still running, or is in an unknown state | failed-tool-needs-review, unfinished-tool-needs-review, unknown-tool-state |
The heart of it is two checks. First, only a structured control-plane code counts—English prose is never matched:
const code = structured.error?.codexErrorInfo
?? (lastError?.willRetry === false ? lastError.error?.codexErrorInfo : undefined);
if (code !== 'usageLimitExceeded') return { switch: false, reason: 'other-provider-error' };
Second, if any command, file change, MCP call, or web search failed or was left hanging, a human needs to look before another model touches the repo:
if (item.status === 'failed' || (item.type === 'command_execution' && item.exit_code !== 0)) {
return { switch: false, reason: 'failed-tool-needs-review' };
}
// ...
if (pending.size) return { switch: false, reason: 'unfinished-tool-needs-review' };
return { switch: true, reason: 'subscription-allowance-exhausted' };
When the answer finally is yes, the orchestrator hashes every tracked and untracked file (workspaceSnapshot()), writes an atomic handoff.json journal under an exclusive lock so a failed fallback can never auto-retry, and hands Bedrock a pessimistic spending guard.
That guard, requestBudget(), doesn't trust usage counters that arrive after the fact. Before the bridge forwards a single byte, it reserves the worst case—a full 128k-token context plus the capped output—persists the ledger to disk, and never refunds:
const reserveMicros = Math.ceil(
128000 * inputUsdPerMillion + maxOutputTokens * outputUsdPerMillion
);
// ...
if (ledger.requests >= maxRequests
|| ledger.reservedMicros + reserveMicros > Math.floor(maxUsd * 1e6)) {
throw new Error('Bedrock request budget exhausted; no request forwarded');
}
ledger.requests++;
ledger.reservedMicros += reserveMicros;
await onReserve({ ...ledger }); // Persist before forwarding; never refund.
At the defaults (maxRequests: 8, maxOutputTokens: 4096, maxUsd: 1, USD 1/million planning rates), seven full-context reservations fit in the budget; the eighth is blocked before it leaves the machine. It's not an AWS billing cap, and the rates are conservative assumptions rather than live pricing. It felt like over-engineering when I wrote it. Remember it.
Into the cloud #
Running locally proved the protocol. Running in AWS tests the operational edges: credential isolation, durable storage on NFS, exclusive locking, and least-privilege IAM.
To keep the blast radius small, rock-in-the-bed/cloud/ is a private, single-user, one-job ECS Fargate worker in us-east-1. No ECS service, no load balancer, no inbound security-group rules, no automatic retry, no Git push credentials. Each job pulls a version-pinned Git bundle from S3, runs once, and leaves its checkout and logs on encrypted EFS for inspection:
Operator ── bundle → S3 (pinned version) ── image → ECR (@sha256) ── auth.json → Secrets Manager
│
└─ aws ecs run-task ──► Fargate task (read-only rootfs, UID 1000, egress 443 + NFS only)
├─ App Server ───────────────► OpenAI (subscription)
├─ oss-bridge (loopback) ────► Bedrock Mantle (gpt-oss-20b)
├─ state ────────────────────► encrypted EFS
└─ 4 phase events only ──────► CloudWatch
Full architecture diagram:
Operator (local CLI)
| 1. upload Git bundle + manifest -> S3 (pinned VersionId)
| 2. push immutable image -> ECR (pinned @sha256 digest)
| 3. populate auth.json -> Secrets Manager
| 4. aws ecs run-task (manifest key + version only; no secrets)
v
+----------------------------------------------------------------------------+
| AWS Region: us-east-1 |
| |
| Bootstrap Stack (durable inputs, DeletionPolicy: Retain) |
| +--------------------+ +--------------------+ +----------------------+ |
| | S3 Input Bucket | | ECR Repository | | Secrets Manager | |
| | versioned, AES256, | | immutable tags, | | personal Codex | |
| | TLS-only, private | | scan-on-push | | auth.json seed | |
| +---------+----------+ +---------+----------+ +----------+-----------+ |
| | | | |
| | TaskRole: | ExecutionRole: | TaskRole: |
| | GetObject (inputs/*) | pull digest + logs | GetSecret |
| v v v |
| Worker Stack (VPC across 2 AZs; no service, no LB, no inbound SG rules) |
| +----------------------------------------------------------------------+ |
| | ECS Fargate Task (2 vCPU / 4 GiB, UID 1000, read-only rootfs) | |
| | SG egress: TCP 443 (HTTPS) + TCP 2049 (NFS to EFS SG only) | |
| | | |
| | worker.mjs -> task.mjs -> App Server (subscription leg) | |
| | | | |
| | +-> on usageLimitExceeded (or planned fork): | |
| | local oss-bridge.mjs (loopback + SigV4) | |
| | | |
| | /scratch (ephemeral): CODEX_SQLITE_HOME (snapshotted on exit) | |
| +----------+----------------------------+-----------------------+------+ |
| | NFS/TLS (2049) | operational JSON | |
| | IAM auth, UID/GID 1000 | phase events only | |
| v v | |
| +------------------------------+ +--------------------------+ | |
| | Encrypted EFS (2 AZ mounts) | | CloudWatch Log Group | | |
| | Access Point: /data | | /ecs/rock-in-the-bed-... | | |
| | .account.lock, auth, repo | | (no prompts, tokens, or | | |
| | checkouts, rollouts, reports | | model output) | | |
| +------------------------------+ +--------------------------+ | |
| | |
+------------------------------------------------------------------+---------+
|
Outbound HTTPS (TCP 443) |
+-------------------------------------------+
v v
+-------------------------+ +-----------------------------------+
| OpenAI (Subscription) | | Amazon Bedrock Mantle (us-east-1) |
| Codex App Server turn | | openai.gpt-oss-20b |
| | | POST /v1/responses |
| | | bedrock-mantle:CreateInference |
+-------------------------+ +-----------------------------------+
Three traps were waiting in the cloud layer:
Trap 1: Mantle doesn't care about bedrock:InvokeModel. Bedrock Mantle has its own IAM action namespace, so a policy built around the usual Bedrock Runtime actions doesn't cover it. In cloud/worker.template.json, the task role allows exactly one action, on exactly one model, in exactly one region:
{
"Sid": "GptOssMantleOnly",
"Effect": "Allow",
"Action": "bedrock-mantle:CreateInference",
"Resource": {
"Fn::Sub": "arn:${AWS::Partition}:bedrock-mantle:us-east-1:${AWS::AccountId}:project/*"
},
"Condition": {
"StringEquals": {
"bedrock-mantle:Model": "openai.gpt-oss-20b",
"aws:RequestedRegion": "us-east-1"
}
}
}
Trap 2: SQLite on NFS is a locking horror story waiting to happen. Following OpenAI's NFS guidance,[5] cloud/worker.mjs points CODEX_SQLITE_HOME at task-local /scratch and copies an offline snapshot back to EFS only after Codex exits. Rollouts stay durable on EFS, and an exclusive .account.lock (open(lockPath, 'wx', 0o600)) guarantees two jobs never race on ChatGPT refresh tokens.
Trap 3: an agent that can run shell commands can read your AWS credentials. Before spawning Codex or the user's --check command, taskEnvironment() in local/task.mjs strips every AWS_*, GIT_*, and OpenAI API-key variable. Only the credential-export subprocess feeding the loopback bridge sees ECS's container credential URI. CloudWatch receives nothing but four tiny phase events (preparing, running, completed, stopped)—never prompts, tokens, or model output.
With both CloudFormation stacks deployed, the first cloud runs looked great: a subscription-only smoke job passed, a synthetic-failure handoff passed in 5 Bedrock requests, and a planned two-stage continuation (planned-handoff-20261130-01) recalled the secret marker and passed its independent check.
Infrastructure green. Marker recalled. Check passed. It felt like the finish line.
Three tasks, three failures #
I queued three slightly harder tasks—slug, invoice, and tags—expecting a victory lap. Each had a stage-1 check on the subscription and a stage-2 check on Bedrock.
All three sailed through the subscription stage. All three handed off cleanly. All three failed.
| Cloud job | Subscription stage | Bedrock leg | Final outcome |
|---|---|---|---|
series-slug-20261130-01 |
Passed | 7/7 budgeted requests consumed; 8th rejected by budget | Stopped |
series-invoice-20261130-01 |
Passed | 7/7 budgeted requests consumed; 8th rejected by budget | Stopped |
series-tags-20261130-01 |
Passed | 5/5 requests; marker recalled | Final check failed |
Look at the first two rows. That's the "over-engineered" budget guard from earlier, doing exactly what it was built for. Without it, whatever was going wrong would have kept billing me until someone noticed.
Every piece of infrastructure—S3 pinning, Secrets Manager, EFS, IAM—had done its job. So why was GPT-OSS-20B suddenly flailing?
A read-only diagnostic task pulled the retained bedrock.stderr.log files. The same error repeated across all three runs:
ERROR codex_core::tools::router: error=unsupported call: exec
ERROR codex_core::tools::router: error=unsupported call: exec<|channel|>commentary
ERROR codex_core::tools::router: error=unsupported call: execcommentary
Then I checked the stderr of that 12-request local run from two days earlier. Same errors. The clue had been sitting there the whole time; the run had simply passed despite it.
Two questions. Why was the model calling a tool named exec when Codex's active tools were exec_command, write_stdin, and apply_patch? And what was <|channel|>commentary doing glued to the end of it?
The second one has a quick answer. GPT-OSS was trained on Harmony, OpenAI's chat format for its open-weight models, which uses special tokens like <|channel|> to separate reasoning (analysis), tool calls (commentary), and answers (final). A 20B model occasionally leaks those tokens into places they don't belong—like a tool name.
The first question took a captured fork payload: request-capture.json, 114.8 KB of what the bridge actually sent to Mantle. A few lines in, the bug was painfully obvious:
[ 1] additional_tools bytes=30,043 tools=['functions', 'clock', 'collaboration']
...
[ 9] custom_tool_call name=exec input='text(await tools.exec_command({cmd:"cat greet.mjs"}))'
[10] custom_tool_call_output output='Script completed...'
[11] custom_tool_call name=exec input='text(await tools.apply_patch("*** Begin Patch..."))'
[12] custom_tool_call_output output='Script completed...'
I had sabotaged the fallback model myself:
- The subscription model runs its tools through a JavaScript REPL called
exec. During stage 1, it never calledexec_commandorapply_patchdirectly; it called a freeformexectool with JS snippets that called them. - My adapter turned those into live
function_callitems namedexec. Mantle's Harmony template rendered them as assistant calls tofunctions.exec—a function that did not exist in GPT-OSS-20B's tool list. - I also dumped 30 KB of
execdocumentation into the prompt. My translation ofadditional_toolsserialized the entire retired tool namespace into a developer message.
Now put yourself in the shoes of a 20B open-weight model doing in-context imitation. You're shown 30 KB of documentation for functions.exec. You see your own earlier turns calling exec, successfully. So you call exec. The router rejects it. You try again, occasionally garbling your channel tokens. Rejected again. And again—until a USD 1 budget guard pulls the plug on request seven.
The model wasn't stupid. It was doing exactly what the transcript taught it to do. I was haunting it with the ghosts of tools it could never call.
Exorcising the ghosts #
The fix belongs in local/oss-bridge.mjs (plus one explicit sentence in local/gpt-oss-catalog.json), and it doesn't drop a single byte of actual work history.
First, normalizeRequest() now resolves the active tools[] list before walking the history. A historical call to an active tool like apply_patch stays a paired function_call / function_call_output. A call to a retired tool like exec is preserved verbatim—but as plain text, clearly labelled as history. GPT-OSS-20B still sees every command and output from stage 1, without ever seeing a tool call to a function it can't use. And additional_tools shrinks to a one-line note listing retired vs. callable tools, cutting the fork payload from 114.8 KB to 84.1 KB:
if (item.type === 'custom_tool_call') {
if (activeToolNames.has(item.name)) {
return {
type: 'function_call',
call_id: item.call_id,
name: item.name,
arguments: JSON.stringify({ input: item.input }),
};
}
retiredCallIds.set(item.call_id, item.name);
return {
type: 'message',
role: 'assistant',
content: `[Historical ${item.name} tool call ${item.call_id} from earlier provider; `
+ `${item.name} is unavailable now — do not call ${item.name}]\n${item.input}`,
};
}
Second, for Harmony leakage on real tools, normalizeToolName() in responseTranslator() strips a leading functions., any <|... control tokens, and glued commentary / analysis / final suffixes—if and only if the cleaned name exactly matches an active tool:
export function normalizeToolName(name, activeToolNames = new Set()) {
if (typeof name !== 'string' || !name || !activeToolNames.size || activeToolNames.has(name)) {
return name;
}
let candidate = name.replace(/^functions\./, '');
const tokenIndex = candidate.indexOf('<|');
if (tokenIndex !== -1) candidate = candidate.slice(0, tokenIndex);
candidate = candidate.trim();
if (activeToolNames.has(candidate)) return candidate;
for (const suffix of ['commentary', 'analysis', 'final']) {
if (candidate.endsWith(suffix)) {
const stripped = candidate.slice(0, -suffix.length).trim();
if (activeToolNames.has(stripped)) return stripped;
}
}
return name; // Unknown tools like `exec` stay rejected honestly.
}
Because it runs before the apply_patch conversion, even a mangled apply_patch<|channel|>commentary gets cleaned and delivered as a native custom_tool_call. A hallucinated exec never matches, so the bridge never guesses.
Before and after #
To isolate the fix, I re-forked the exact same saved thread from two days earlier—the 12-request one—through the updated bridge:
| Metric on the same saved thread | Before fix | After fix |
|---|---|---|
| Bedrock requests | 12 | 4 |
| Codex tool-router stderr errors | 6 (exec, exec<|channel|>commentary, apply_patch, JSON parse) |
0 |
| Live Harmony tool-name sanitizations | n/a | 1 (apply_patch recovered on turn 2) |
| Conversation marker & stage-2 test | Passed | Passed (11 seconds) |
Requests dropped by two-thirds, stderr went silent, and the new sanitizer earned its keep immediately by rescuing a corrupted apply_patch call on turn 2.
Then the limit hit for real #
There was one thing I'd never been able to test honestly. Every handoff so far had been planned or simulated, because you can't exhaust a subscription on demand.
And then, with the fix verified and nothing left to fake, my Codex subscription ran out. For real. I'd spent three days building a tool for exactly this moment, and the moment finally showed up on its own.
App Server emitted the exact structured sequence handoffDecision() had been waiting for:
{"method": "error", "params": {"error": {"codexErrorInfo": "usageLimitExceeded", "message": "You’ve hit your usage limit..."}}}
{"method": "turn/completed", "params": {"turn": {"status": "failed", "error": {"codexErrorInfo": "usageLimitExceeded"}}}}
No --simulate-allowance. No mock server. Just a real limit, and an orchestrator that knew what to do with it. I ran the full automatic fallback twice:
- Locally (
npm run taskon aslugifyrepository): App Server returnedusageLimitExceeded, the orchestrator classified it assubscription-allowance-exhausted, checkpointed the repo, forked the thread to GPT-OSS-20B, finished the edit in 4 Bedrock requests with zero stderr errors (one nativeapply_patchcall), and passednode test-stage2.mjs. - On ECS Fargate: after all 70 unit tests passed on the host and inside the rebuilt
linux/amd64image, I pushed immutable imagebridge-fix-20261130-01, pinned the worker to its new@sha256digest, and launchedbridge-fix-slug-20261130-01. Fifty-nine seconds later, the task exited0:
{"jobId":"bridge-fix-slug-20261130-01","phase":"preparing"}
{"jobId":"bridge-fix-slug-20261130-01","phase":"running"}
{"jobId":"bridge-fix-slug-20261130-01","phase":"completed"}
Three lines of CloudWatch. After three days, it was the most satisfying log I'd read all week.
Try it locally #
The code lives under rock-in-the-bed/ (Node.js 22+, pinned @openai/codex 0.171.0). You can run the test suite and the offline handoff demo without touching AWS or spending subscription tokens:
cd rock-in-the-bed
npm ci
npm test
npm run continuity -- --dry-run
node local/handoff-demo.mjs
To run a real task against a local Git repository with automatic Bedrock failover (requires an active Codex login and an AWS profile with openai.gpt-oss-20b access in us-east-1):
npm run task -- \
--repo /path/to/repository \
--prompt 'Fix the failing tests and explain the change.' \
--check 'npm test' \
--aws-profile dev \
--aws-region us-east-1
Conclusion #
The original question has an answer: a Codex task can detect a naturally occurring subscription limit, cross the provider boundary onto Bedrock GPT-OSS-20B with its history and workspace intact, adapt retired tool protocols on the fly, and pass an independent check—both locally and on ECS Fargate.
It's still a proof of mechanics, not a product:
- Mid-task exhaustion: both natural-exhaustion runs hit the limit on turn 1, before any edits. Mid-task continuity was verified with planned forks and synthetic failures. Recovering from an interrupted shell command or partial edit still needs manual review, and nothing here guarantees exactly-once execution.
- Model capability: fixing
greet.mjsandslug.mjsdoesn't mean a 20B model can carry a complex multi-file refactor. - Switching back: returning to the subscription after the allowance resets isn't built yet, and
requestBudget()is a per-run guard, not an AWS billing cap. - Authentication: the Fargate worker used a personal headless login seeded via Secrets Manager for single-user testing. A hosted or multi-user version would need a provider-supported authentication integration.
But the next time Codex tells me I've hit my limit halfway through a task, the session doesn't have to end. It forks, crosses over to Bedrock, and keeps going: same files, same history, same marker. Whether it can carry a real refactor across that line is the next experiment, and openai.gpt-oss-120b is already authorized and waiting behind the same bridge.
Source code #
Reference implementation (opens in a new tab)