Headless Event & Cron Orchestrator
Overview This skill designs autonomous ADK work as a durable event processor, not an interactive chat session. It specifies an authenticated ingress, base64 Pub/Sub structured observability, and session compaction. It includes a local mock launcher and a Cloud Scheduler Terraform template, but never deploys cloud resources or starts a production worker without explicit approval.
Prerequisites
A version-pinned ADK/FastAPI application and a declared task contract.
Pub/Sub topic/subscription or a Cloud Scheduler job owned by the deployment team; least-privilege service accounts and an authenticated HTTP target.
A durable idempotency/event store and a redaction policy for logs/events.
Workflow
Step 1: Define the event contract and ownership Assign every event an immutable ID, source, schema version, occurred time, tenant/user boundary, and idempotency key. The handler must acknowledge only backoff, dead-letter topic, retention, and a human owner for poison events. Never use an in-memory set as production idempotency storage.
Step 2: Build authenticated ingress and bounded execution Read
references/ambient_agents_api.md. Verify the scheduler/Pub/Sub caller identity before decoding payloads, enforce request-size limits, decodemessage.datafrom base64, validate schema, and place work on a bounded queue. FastAPI lifespan initializes shared clients and drains/cleans them on shutdown; it must not launch an unbounded background task per inbound request. Log event IDs and decisions, never raw credentials or user-sensitive payloads.Step 3: Make processing idempotent and failure-aware Deduplicate before side effects and record state transitions such as received, running, succeeded, retryable-failed, and permanently-failed. Retry only transient faults; route deterministic validation/tool-policy failures to DLQ with a sanitized reason. Do not retry a non-idempotent external action unless its provider supports an idempotency key and the original key was recorded durably before the first attempt.
Step 4: Bound session history Read
references/context_compaction_patterns.md. Configure compaction before the context window approaches exhaustion, retain a fixed recent-event tail, anLlmEventSummarizeronly after confirming its exact constructor/config names in the installed ADK version. Summaries are lossy: never compact audit evidence, authorization data, or a pending approval state into model-only text.Step 5: Test locally, then provide deployment artifacts Run
scripts/run_ambient_worker.sh --mock-event '{"id":"e-1","task":"test"}'. It validates and base64-encodes a mock Pub/Sub envelope locally; it does not call Google APIs or launch FastAPI. Fillassets/cloud_scheduler_cron.tfwith the authenticated endpoint and service account, then hand it to the infrastructure owner for review. Do not runterraform applyor create subscriptions from this skill.Examples
Example 1: Scheduled nightly reconciliation Use Cloud Scheduler to publish an event ID/date to Pub/Sub, deduplicate by date/task, process with bounded concurrency, and DLQ malformed events. Report the run ID and compact only ordinary conversation history.
Example 2: Pub/Sub document update Authenticate push delivery, decode only validated base64 data, persist the event ID before calling the agent/tool, and redact document contents from logs.
Error Handling
Invalid base64/schema: emit sanitized validation error and DLQ; do not invoke the agent.
Duplicate event: return the stored terminal state; do not repeat side effects.
Compaction failure: preserve current state and fail/retry safely; do not drop history and continue.
Shutdown: stop accepting work, wait a bounded time for in-flight events, then leave incomplete work retryable in durable storage.
Reference Files
references/ambient_agents_api.md: FastAPI/Pub/Sub worker design.
references/context_compaction_patterns.md: compaction safeguards.
scripts/run_ambient_worker.sh: local no-network envelope mock.
assets/cloud_scheduler_cron.tf: review-only Scheduler Terraform block.
Output Format Return event contract; auth/idempotency/DLQ design; compaction strategy; structured logging fields; local mock result; and review-only Terraform.
Adk Long Horizon Harness
Designs and operates headless, long-running ADK agents triggered by Pub/Sub events or Cloud Scheduler cron jobs, with idempotent event handling, structured logs, retries/dead-lettering, and session-context compaction. TRIGGER when users ask to 'build an event-driven ADK agent', 'run ADK on a cron schedule', 'configure Pub/Sub triggers', 'manage long-running background tasks', or use `EventsCompactionConfig`/`LlmEventSummarizer` to summarize session history. DO NOT TRIGGER for interactive single-request ADK agents, generic FastAPI endpoints without an autonomous worker, or one-time local scripts.
Adk Long Horizon Harness by tommywagz · ff35ea0
npx skillmds@latest add tommywagz/adk-long-horizon-harness File contents
---name: adk-long-horizon-harnessdescription: Designs and operates headless, long-running ADK agents triggered by Pub/Sub events or Cloud Scheduler cron jobs, with idempotent event handling, structured logs, retries/dead-lettering, and session-context compaction. TRIGGER when users ask to 'build an event-driven ADK agent', 'run ADK on a cron schedule', 'configure Pub/Sub triggers', 'manage long-running background tasks', or use `EventsCompactionConfig`/`LlmEventSummarizer` to summarize session history. DO NOT TRIGGER for interactive single-request ADK agents, generic FastAPI endpoints without an autonomous worker, or one-time local scripts.license: Apache-2.0---- Headless Event & Cron Orchestrator- OverviewThis skill designs autonomous ADK work as a durable event processor, not aninteractive chat session. It specifies an authenticated ingress, base64 Pub/Substructured observability, and session compaction. It includes a local mocklauncher and a Cloud Scheduler Terraform template, but never deploys cloudresources or starts a production worker without explicit approval.- Prerequisites- A version-pinned ADK/FastAPI application and a declared task contract.- Pub/Sub topic/subscription or a Cloud Scheduler job owned by the deploymentteam; least-privilege service accounts and an authenticated HTTP target.- A durable idempotency/event store and a redaction policy for logs/events.- Workflow- Step 1: Define the event contract and ownershipAssign every event an immutable ID, source, schema version, occurred time,tenant/user boundary, and idempotency key. The handler must acknowledge onlybackoff, dead-letter topic, retention, and a human owner for poison events.Never use an in-memory set as production idempotency storage.- Step 2: Build authenticated ingress and bounded executionRead `references/ambient_agents_api.md`. Verify the scheduler/Pub/Sub calleridentity before decoding payloads, enforce request-size limits, decode`message.data` from base64, validate schema, and place work on a bounded queue.FastAPI lifespan initializes shared clients and drains/cleans them on shutdown;it must not launch an unbounded background task per inbound request. Log eventIDs and decisions, never raw credentials or user-sensitive payloads.- Step 3: Make processing idempotent and failure-awareDeduplicate before side effects and record state transitions such as received,running, succeeded, retryable-failed, and permanently-failed. Retry onlytransient faults; route deterministic validation/tool-policy failures to DLQwith a sanitized reason. Do not retry a non-idempotent external action unlessits provider supports an idempotency key and the original key was recordeddurably before the first attempt.- Step 4: Bound session historyRead `references/context_compaction_patterns.md`. Configure compaction beforethe context window approaches exhaustion, retain a fixed recent-event tail,an `LlmEventSummarizer` only after confirming its exact constructor/confignames in the installed ADK version. Summaries are lossy: never compact auditevidence, authorization data, or a pending approval state into model-only text.- Step 5: Test locally, then provide deployment artifactsRun `scripts/run_ambient_worker.sh --mock-event '{"id":"e-1","task":"test"}'`.It validates and base64-encodes a mock Pub/Sub envelope locally; it does notcall Google APIs or launch FastAPI. Fill`assets/cloud_scheduler_cron.tf` with the authenticated endpoint and serviceaccount, then hand it to the infrastructure owner for review. Do not run`terraform apply` or create subscriptions from this skill.- Examples- Example 1: Scheduled nightly reconciliationUse Cloud Scheduler to publish an event ID/date to Pub/Sub, deduplicate bydate/task, process with bounded concurrency, and DLQ malformed events. Reportthe run ID and compact only ordinary conversation history.- Example 2: Pub/Sub document updateAuthenticate push delivery, decode only validated base64 data, persist theevent ID before calling the agent/tool, and redact document contents from logs.- Error Handling- Invalid base64/schema: emit sanitized validation error and DLQ; do not invokethe agent.- Duplicate event: return the stored terminal state; do not repeat side effects.- Compaction failure: preserve current state and fail/retry safely; do not drophistory and continue.- Shutdown: stop accepting work, wait a bounded time for in-flight events, thenleave incomplete work retryable in durable storage.- Reference Files- **references/ambient_agents_api.md**: FastAPI/Pub/Sub worker design.- **references/context_compaction_patterns.md**: compaction safeguards.- **scripts/run_ambient_worker.sh**: local no-network envelope mock.- **assets/cloud_scheduler_cron.tf**: review-only Scheduler Terraform block.- Output FormatReturn event contract; auth/idempotency/DLQ design; compaction strategy;structured logging fields; local mock result; and review-only Terraform.
tommywagz/Gemini-Enterprise-Skills/tree/main/skills/adk-long-horizon-harness commit ff35ea0ae7
Frequently asked questions
Run npx skillmds@latest add tommywagz/adk-long-horizon-harness in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Designs and operates headless, long-running ADK agents triggered by Pub/Sub events or Cloud Scheduler cron jobs, with idempotent event handling, structured logs, retries/dead-lettering, and session-context compaction. TRIGGER when users ask to 'build an event-driven ADK agent', 'run ADK on a cron schedule', 'configure Pub/Sub triggers', 'manage long-running background tasks', or use `EventsCompactionConfig`/`LlmEventSummarizer` to summarize session history. DO NOT TRIGGER for interactive single-request ADK agents, generic FastAPI endpoints without an autonomous worker, or one-time local scripts. It is listed under DevOps & Infra on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free. This skill is licensed under Apache-2.
tommywagz (@tommywagz) published this skill. Their other Agent Skills are listed on their SkillMD profile.