Skip to main content

boilerplate-devops-investigation-agent

The generic base for a DevOps investigation agent. Import it as devops_agent. A concrete agent installs this package and adds its own phase handlers, prompts and models. This package holds no prompts, models, accounts or log sources.

It provides:

  • the investigation-phase/1.0.0 protocol: JSON schemas (draft 2020-12) and pydantic models;
  • an async HTTP shell with the AgentCore contract: GET /ping and POST /invocations;
  • a result writer that appends one Run event to a Redis stream with XADD;
  • an invocation store, so a repeated request starts no new work;
  • a per-job limit and deadline guard that counts every model call and query;
  • a bounded CloudWatch Logs read tool;
  • optional parts: a Deep Agent factory (devops_agent.agent, extra deep-agent) and a Podman code worker (devops_agent.sandbox).

Install

pip install boilerplate-devops-investigation-agent
pip install "boilerplate-devops-investigation-agent[deep-agent]"  # optional Deep Agent factory

How a phase job runs

  1. The harness sends a request to POST /invocations.
  2. The shell checks it. Unknown fields, run_settings and a wrong phase and operation pair are refused with 422. A repeated invocation_id with a different body gets 409.
  3. The shell replies at once with the acknowledgement: {"protocol_version": "investigation-phase/1.0.0", "invocation_id": "...", "request_sha256": "...", "accepted": true}.
  4. The phase handler runs in a worker thread. /ping reports HealthyBusy until it ends.
  5. The writer appends exactly one entry to the request's result_stream: XADD <result_stream> * json <document>. The document is a canonical Run event of kind phase_result (format version 2). Its payload is the protocol result.

The invocation_id is opaque text of 1 to 256 characters, for example run-1:0:frame. The base never parses it. The acknowledgement and the result carry it back unchanged.

A handler failure, a limit or a passed deadline still writes one result, with status: "error" and error.kind set to handler, limit, deadline or invalid_output.

A failed Redis write is logged and not retried, because a retry could write a second result. A repeated request with the same body then gets the acknowledgement again but starts no work. Only the harness phase deadline ends that job.

The invocation store is in memory by default. After an agent restart, a repeated request runs again and may write a second result. The harness ignores a second result for the same invocation_id, so this is safe.

Wire a concrete agent

import redis
from devops_agent.guard import PhaseGuard
from devops_agent.protocol import AgentInfo, PhaseRequest
from devops_agent.results import RedisResultWriter
from devops_agent.runtime import create_app


def frame(request: PhaseRequest, guard: PhaseGuard) -> dict:
    with guard.model_call(role="frame", model_id=MODEL_ID, max_microdollars=40_000) as call:
        reply = my_model.invoke(...)
        call.settle(input_tokens=..., output_tokens=..., microdollars=...)
    return {"directions": [...]}


app = create_app(
    {"FRAME": frame},  # one handler for each phase you serve
    writer=RedisResultWriter(redis.Redis.from_url(REDIS_URL, decode_responses=True)),
    agent=AgentInfo(version="1.0.0", commit=GIT_COMMIT, prompt_set_sha256=PROMPT_HASH),
)

Without a writer and an agent block, the app refuses every request with 503. A phase with no handler is refused with 503 too.

The guard is made from the request's limits and deadline. Before each call, it reserves the worst-case price, so spend never passes money_microdollars. A call that is not settled keeps its whole reservation as spent. The first refusal stops the guard, so no model call follows a limit. The guard's totals become the result's cost.

Give the CloudWatch tool the same guard, so each read counts as one query:

from devops_agent.tools import make_read_logs_tool

read_logs = make_read_logs_tool(
    logs_client, allowed_groups=set(request.source.log_groups),
    start_ms=start_ms, end_ms=end_ms, guard=guard,
)

Protocol files

The schemas ship inside the package:

from devops_agent.protocol import load_schema

load_schema("request")  # also "acknowledgement" and "result"

They live at devops_agent/protocol/investigation-phase/1.0.0/*.schema.json.

Phase Operation input output
FRAME frame leads directions: 1 to 4 objects with window and hint
QUALIFY qualify directions passed, reason
GENERATE action direction, diver_id result: status, content, hypotheses, evidence, handoff
RANK rank candidates: id, content, listing scores: id, score, reason for each candidate
EXECUTE execute selected: id, content, score; mode plan for plan_log, or proposal for medic_proposal

Directions, diver results, plans and proposals are open objects. Only their required top-level keys are checked.

Local development

Install uv, Make and Podman.

make setup
make test
make start   # an unwired shell at http://127.0.0.1:8080/ping

The Redis tests start a disposable Podman Redis on 127.0.0.1 from docker.io/library/redis:7-alpine and stop it afterwards. To use your own Podman Redis, set REDIS_URL=redis://127.0.0.1:<port>. Never use a host Redis.

Release

make publish checks that PYPI_APITOKEN starts with pypi-, builds the wheel and sdist, runs scripts/check_release_content.py on them, uploads with uv and tags v<version>. The content check refuses account ids, ARNs, AWS log group names, URLs that are not allowed, access keys, private keys and tokens.

License

MIT. See LICENSE.

Metadata

Release files for boilerplate-devops-investigation-agent 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for boilerplate-devops-investigation-agent 0.2.1
File Size Uploaded Provenance Actions
boilerplate_devops_investigation_agent-0.2.1.tar.gz 39.8 kB Without provenance Details for boilerplate_devops_investigation_agent-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for boilerplate-devops-investigation-agent 0.2.1
File Interpreter ABI Platform Actions
boilerplate_devops_investigation_agent-0.2.1-py3-none-any.whl Python 3 none any Details for boilerplate_devops_investigation_agent-0.2.1-py3-none-any.whl

Total release size: 67.6 kB

Release files / boilerplate_devops_investigation_agent-0.2.1.tar.gz

Download URL boilerplate_devops_investigation_agent-0.2.1.tar.gz
Size 39.8 kB
Tags Source
SHA-256 checksum
How to use checksums
da709c2dc4c6ad2dc2258cd37df362b862ac74b01e0cc61a0db5ce00d73cb5e6
BLAKE2b-256 checksum
How to use checksums
92093b73695529d9fd63cb45b284bb40973d772ad9b5d76e44607e8296637c60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / boilerplate_devops_investigation_agent-0.2.1-py3-none-any.whl

Download URL boilerplate_devops_investigation_agent-0.2.1-py3-none-any.whl
Size 27.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5c06cf9e85f634d45fcb4ce3d0701e7877233f0862b6fbe8ba5962bacfbdd777
BLAKE2b-256 checksum
How to use checksums
2de16f6191cee6eb0db4d67fe4e5bc97e14a606d3b8b9b2df417faf7f34b61e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.3 {"installer":{"name":"uv","version":"0.13.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for boilerplate-devops-investigation-agent 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page