Skip to content

fix(tasks): route hogland agent through the LLM gateway, not direct Bedrock - #95658

Merged
trunk-io[bot] merged 1 commit into
masterfrom
tom/hogland-tasks-disable-bedrock
Sep 5, 2026
Merged

fix(tasks): route hogland agent through the LLM gateway, not direct Bedrock#95658
trunk-io[bot] merged 1 commit into
masterfrom
tom/hogland-tasks-disable-bedrock

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

Problem

hogland task boxes fail because the in-box agent talks to AWS Bedrock directly — hogland boots boxes with the bedrock feature, which exports CLAUDE_CODE_USE_BEDROCK=1. That direct-Bedrock path has hit a chain of Bedrock-specific failures that the Modal backend never sees:

  1. SigV4 rejects the x-posthog-property-* custom headers (fixed in fix(agent): drop underscore-named custom headers on direct Bedrock #95455), and now
  2. AWS Bedrock Marketplace model-access is denied for the box's role — something the tasks team can't resolve without an AWS-account change.

Modal boxes don't use Bedrock; they route through the PostHog LLM gateway and work fine. hogland used the gateway too until the Bedrock rollout a few days ago.

Changes

  • hogland task runs now route the agent's LLM calls through the PostHog LLM gateway instead of direct Bedrock — the same path Modal uses. At agent-server launch the box's Bedrock env is unset (env -u CLAUDE_CODE_USE_BEDROCK -u AWS_CONTAINER_CREDENTIALS_FULL_URI), so the Claude CLI falls back to the gateway (ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN) the agent already configures.
  • This sidesteps the Bedrock Marketplace/model-access blocker and the SigV4 header issue entirely, and restores gateway-based AI-observability attribution for hogland runs (direct Bedrock bypassed the gateway, so those runs weren't attributed).
  • Mechanical: build_agent_runtime_env_prefix gains unset_bedrock; SandboxBase.disable_direct_bedrock (default False) is set True on HoglandSandbox; the launcher threads it through. Modal/Docker are unchanged.
  • Worker-side only — this runs on the temporal worker when it launches the agent, not baked into the golden, so it deploys with the normal backend (no golden re-bake, no @posthog/agent publish).

How did you test this code?

  • Added 3 unit tests (test_hogland_sandbox.py, all pass locally): HoglandSandbox.disable_direct_bedrock is True; the env prefix emits -u CLAUDE_CODE_USE_BEDROCK -u AWS_CONTAINER_CREDENTIALS_FULL_URI when unset_bedrock=True and neither var by default.
  • Root-caused by end-to-end repro on hogland: direct-Bedrock tasks fail (first SigV4, then the Marketplace access denial); the gateway path (Modal) works. This puts hogland on the working gateway path.
  • Full end-to-end confirmation (re-enable the flag, run a hogland task) will follow once this deploys — no golden re-bake required.

Docs update

Not needed.

🤖 Agent context

Autonomy: Human-driven (agent-assisted).

Follow-on to #95455. After the SigV4 header fix, hogland tasks hit a second, AWS-side Bedrock blocker (Marketplace model-access). Rather than chase each Bedrock-specific issue, this routes hogland tasks through the PostHog LLM gateway — the path Modal already uses successfully and that hogland itself used before the recent Bedrock rollout — which also fixes the AI-observability attribution gap direct Bedrock introduced. hogland's own design intends direct Bedrock (per-box AWS creds, no SaaS keys), so this is a deliberate tasks-product choice to opt our boxes out; worth a heads-up to the hogland team.

…edrock

hogland boxes boot with the `bedrock` feature, which puts the Claude CLI
in direct-Bedrock mode (CLAUDE_CODE_USE_BEDROCK=1). That path has hit a
chain of Bedrock-specific failures (SigV4 header signing, then AWS
Marketplace model-access denial) that Modal never sees because it routes
through the PostHog LLM gateway. Unset the box's Bedrock env at agent
launch so the CLI falls back to the gateway (ANTHROPIC_BASE_URL /
ANTHROPIC_AUTH_TOKEN) the agent already configures — matching Modal and
restoring gateway-based AI-observability attribution. Worker-side only;
no golden re-bake needed.
Copilot AI lite review requested due to automatic review settings September 5, 2026 19:57
@Gilbert09 Gilbert09 added the stamphog Request AI approval (no full review) label Sep 5, 2026
@trunk-io

trunk-io Bot commented Sep 5, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the feature/desktop Feature Tag: Desktop label Sep 5, 2026
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team September 5, 2026 19:59
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

@Gilbert09
Gilbert09 requested a review from a team September 5, 2026 19:59

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

Contained, opt-in-only change (default False) for one sandbox backend, backed by unit tests, with no deny-listed CI/deploy/auth-of-users/dependency/schema surface touched; reverts to a previously working routing path.

  • Author wrote 0% of the modified lines and has 7 merged PRs in these paths (familiarity MODERATE).
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 24L, 3F substantive, 42L/4F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1b-small (42L, 4F, single-area, fix)
stamphog 2.0.0b4 .stamphog/policy.yml @ 1a3326a · reviewed head 1a3326a

@trunk-io

trunk-io Bot commented Sep 5, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@talyn-app

talyn-app Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

/trunk merge

@trunk-io
trunk-io Bot merged commit aea48fc into master Sep 5, 2026
294 of 301 checks passed
@trunk-io
trunk-io Bot deleted the tom/hogland-tasks-disable-bedrock branch September 5, 2026 20:38
@deployment-status-posthog

deployment-status-posthog Bot commented Sep 5, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-09-05 21:00 UTC Run
prod-us ✅ Deployed 2026-09-05 21:22 UTC Run
prod-eu ✅ Deployed 2026-09-05 21:19 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature/desktop Feature Tag: Desktop stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants