debugging-local-task-agent-runs
Skill727 starsChanged yesterdayMITView on GitHub
Debug the output of local PostHog task runs — the wizard cloud-run path that executes inside a Docker sandbox under the local Temporal `process-task` workflow (the wizard that integrates PostHog, then the coding agent that commits and opens the PR). Use when a local run looks stuck, failed, or silent, or when you need to read the wizard or agent logs. Covers the `.env.local` keys + `ai_features` intent required for cloud runs locally, finding the task UUID (docker ps, temporal CLI, Temporal UI at localhost:8081), tailing live logs inside the sandbox container (`/tmp/posthog-wizard.log`, `/tmp/agent-server.log`), and reading the durable per-run console log from object storage after the sandbox is torn down. Trigger terms: task-sandbox, run_wizard, agent-server, process-task, SANDBOX_PROVIDER, LLM_GATEWAY, cloud_run, posthog-wizard.log.
- Reads credentials
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 36
After editing .env.local, restart the stack — env is read at process start, not hot-reloaded.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Debugging local task/agent runs
A "cloud run" of the Tasks product (e.g. the setup-wizard cloud_run endpoint) executes as the Temporal process-task workflow on the development-task-queue. Locally (SANDBOX_PROVIDER=docker) each run gets a Docker sandbox container in which two things happen in sequence:
run_wizardactivity — runs the published@posthog/wizardto integrate PostHog (writes/tmp/posthog-wizard.log).agent-server— the coding agent that commits the wizard's changes, opens the PR, and keeps it green (writes/tmp/agent-server.log).
The hard part of debugging is that the Temporal UI doesn't show this output — workflow result/failure payloads are binary/encrypted, and the activity captures the wizard/agent output to the run's logs, not to the timeline. This skill is how you actually read it.
Prerequisites: env for local cloud runs
Cloud runs only work locally if all of these are set in .env.local (values shown are the local targets — never commit real secrets). Inside the Docker sandbox, localhost is the container itself, so PostHog URLs use host.docker.internal.
| Key | Purpose / local value |
SANDBOX_PROVIDER | "docker" — route sandboxes to local Docker instead of Modal |
SANDBOX_MCP_URL | "http://host.docker.internal:8787/mcp" — MCP server the agent uses |
SANDBOX_LLM_GATEWAY_URL | "http://host.docker.internal:3308" — local LLM gateway the agent routes model calls through |
SANDBOX_JWT_PRIVATE_KEY | signs the scoped sandbox tokens |
GITHUB_APP_CLIENT_ID | your local GitHub App (clone + PR) |
GITHUB_APP_CLIENT_SECRET | "" |
GITHUB_APP_SLUG | "" |
GITHUB_APP_PRIVATE_KEY | "" |
LLM_GATEWAY_ANTHROPIC_API_KEY | real Anthropic key the local gateway proxies to (read via the gateway's LLM_GATEWAY_ env prefix) |
Two non-env requirements, or the keys above are inert:
- The LLM gateway must actually be running on
:3308. It's gated behind thellm_gatewaycapability — enable theai_featuresintent (hogli dev:setup) so thellm-gatewayproc starts.SANDBOX_LLM_GATEWAY_URLpointing at a dead port just yieldsConnectionRefusedfrom the agent. - The wizard OAuth app must exist —
bin/ensure-local-setupprovisions it and setsWIZARD_CLOUD_RUN_OAUTH_CLIENT_ID; without it thecloud_runendpoint returns 404 "not available".
After editing .env.local, restart the stack — env is read at process start, not hot-reloaded.
Step 1 — find the task UUID
You need the task UUID for the container, and sometimes the run UUID for the durable log. The workflow id encodes both: task-processing-<task_id>-<run_id>.
Fastest (no Temporal needed — the sandbox container name carries the task UUID):
docker ps --format '{{.Names}}' | grep task-sandbox
# task-sandbox-<TASK_ID>-<suffix>From the Temporal CLI (lists running/recent process-task workflows with both UUIDs):
docker exec posthog-temporal-admin-tools-1 \
temporal workflow list --address temporal:7233 --namespace default --limit 10 \
| grep process-task
# task-processing-<TASK_ID>-<RUN_ID> process-task RunningFrom the Temporal UI — http://localhost:8081, open the process-task workflow; the id in the URL is task-processing-<TASK_ID>-<RUN_ID>.
Step 2 — tail live logs inside the sandbox (while it's running)
The wizard and agent write line-by-line to files in the container as they run, so this is the only way to watch progress live (the activity buffers stdout and only flushes to the durable log when it finishes).
TASK_ID=<task-uuid-from-step-1>
CID=$(docker ps -q --filter "name=task-sandbox-$TASK_ID")
docker exec "$CID" tail -f /tmp/posthog-wizard.log # wizard stage (full agent SDK detail)
docker exec "$CID" tail -f /tmp/agent-server.log # agent stage (commit + PR + CI loop)Both files are JSON-heavy. For just the readable activity:
docker exec "$CID" tail -f /tmp/agent-server.log \
| grep -iE '"text"|tool_use|error|✔|✖|commit|PR|CI'These files vanish when the sandbox is torn down (on run completion/failure), so grab them while the container is up.
Step 3 — read the durable per-run console log (after teardown)
Everything the wizard and agent emit is persisted to the run's console log in object storage at tasks/logs/team_<id>/task_<id>/run_<run_id>.jsonl. This survives teardown. Read it with the run UUID (last UUID of the workflow id; or TaskRun.objects.filter(task_id=...).latest("created_at")):
RUN_ID=<run-uuid>
flox activate -- bash -c "python manage.py shell <<'PY'
import json
from products.tasks.backend.models import TaskRun
from posthog.storage import object_storage
tr = TaskRun.objects.get(id='$RUN_ID')
print('status:', tr.status)
for line in (object_storage.read(tr.log_url, missing_ok=True) or '').splitlines():
n = json.loads(line).get('notification', {}); m = n.get('method'); p = n.get('params', {})
if m == '_posthog/console':
print(f\"[{p.get('level')}] {p.get('message','')[:300]}\")
elif m == 'session/update': # the agent stage (ACP stream)
u = p.get('update', {}); t = u.get('sessionUpdate')
if t == 'tool_call': print(' tool→', u.get('title') or u.get('kind'))
elif t == 'tool_call_update' and u.get('status'): print(' tool✓', u.get('status'))
PY"Notes on what you'll (not) see here:
- Wizard stdout/verbose lands as
_posthog/consoledebug events, but only afterrun_wizardfinishes (bufferedsandbox.execute). Mid-run, use Step 2. - Agent prose is filtered out.
append_logdropsagent_message_chunkevents to keep the log lean, so the durable log shows what the agent did (tool calls, commits, progress) but not its narration. For the agent's reasoning, read/tmp/agent-server.login the container (Step 2) before teardown.
Common failure signatures
Could not determine cloud region from access token— the wizard hit cloud auth instead of your local instance. Local needs the wizard pointed at the local base URL; seerun_wizard._build_wizard_command(--base-url, DEBUG-gated).Unable to connect to API (ConnectionRefused)from the agent —LLM_GATEWAY_URL=UNSETor the gateway isn't on:3308. CheckSANDBOX_LLM_GATEWAY_URL+ theai_featuresintent (gateway proc).- Auth/4xx from the gateway — the gateway is reachable but has no upstream provider key (
LLM_GATEWAY_ANTHROPIC_API_KEY) or the token lacksllm_gateway:read. - Workflow "running" but nothing happening — it's in the wait loop (CI follow-up / inactivity). The workflow's Temporal Current Details field names what it's waiting on.
Other versions1 project uses a version of this.
Word for word · 1
- PostHog/posthog★ 40k100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository124 other files it gives its agents.
- AGENTS.mdAGENTS.md
- common/AGENTS.mdAGENTS.md
- hog/AGENTS.mdAGENTS.md
- proto/AGENTS.mdAGENTS.md
- rust/AGENTS.mdAGENTS.md
- .cursor/rules/django-python.mdcCursor rule
- .cursor/rules/react-typescript.mdcCursor rule
- .cursor/rules/rust.mdcCursor rule
- adding-activity-loggingSkill
- adding-api-scopesSkill
- adding-inbound-webhooksSkill
- adding-inbox-sourcesSkill
- adding-ingestion-warningsSkill
- adding-mcp-store-serversSkill
- adding-personhog-rpcSkill
- adding-product-alertingSkill
- adding-project-secret-api-key-authSkill
- adding-today-highlightsSkill
- adopting-generated-api-typesSkill
- analyzing-experiment-precompute-canarySkill
- analyzing-experiment-query-performanceSkill
- analyzing-insights-across-teamsSkill
- announcing-behavior-changesSkill
- auditing-llm-gateway-paritySkill
- auditing-warehouse-source-coverageSkill
- authenticating-to-clickhouseSkill
- authoring-ci-workflowsSkill
- building-product-empty-statesSkill
- building-the-toolbarSkill
- clickhouse-migrationsSkill
- debugging-ci-failuresSkill
- debugging-local-replaySkill
- debugging-mcp-analyticsSkill
- debugging-signals-pipelineSkill
- debugging-table-access-deniedSkill
- depot-ciSkill
- depot-container-buildsSkill
- depot-github-runnersSkill
- developing-subscriptionsSkill
- django-migrationsSkill
- django-startup-timeSkill
- documenting-warehouse-sourcesSkill
- editing-agents-mdSkill
- establishing-code-ownershipSkill
- extending-hobby-smoke-testsSkill
- extending-personhog-test-harnessSkill
- finding-llm-gateway-migration-candidatesSkill
- fixing-flaky-testsSkill
- formatting-slack-messagesSkill
- gating-production-deploysSkill
- gating-sensitive-actionsSkill
- generating-clickhouse-query-performance-reportsSkill
- hogliSkill
- implementing-mcp-toolsSkill
- implementing-mcp-ui-appsSkill
- implementing-warehouse-sourcesSkill
- improving-drf-endpointsSkill
- improving-mcp-toolsSkill
- ingestion-pipeline-doctor-nodejsSkill
- instrumenting-first-party-metricsSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

