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;
  • a store-neutral log search form and its LogsQL renderer (devops_agent.search);
  • 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,
)

Log search form

The model fills a LogSearch form: a time window (start, end, with a time zone), filters (key, operator, value), a limit (default 100, at most 1,000) and a sort (field, direction; default time, desc). Operators are equals, not_equals, contains and not_contains. There is no regex. Search message text with a filter on the key message. A plain word match is case-sensitive, and the form's description tells the model so.

from devops_agent.search import LogSearch, render_logsql

search = LogSearch.model_validate_json(model_reply)  # refuses unknown fields and bad values
query = render_logsql(search)
# _time:[2026-11-14T10:00:00Z, 2026-11-14T11:00:00Z) "_msg":"timed out" | sort by ("_time" desc) | limit 100

Every key and value becomes a quoted LogsQL literal, so a value cannot add a filter or a pipe. message and time become the VictoriaLogs fields _msg and _time. The caller sends the query with its own row limit and timeout.

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.3.0

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.3.0
File Size Uploaded Provenance Actions
boilerplate_devops_investigation_agent-0.3.0.tar.gz 43.4 kB Without provenance Details for boilerplate_devops_investigation_agent-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 73.7 kB

Release files / boilerplate_devops_investigation_agent-0.3.0.tar.gz

Download URL boilerplate_devops_investigation_agent-0.3.0.tar.gz
Size 43.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9c3b5ca639d1c6ac935d4b90eac62589d26c3b7e40fb6987aa1749600745a75b
BLAKE2b-256 checksum
How to use checksums
3d517feeb48c659d14810fc12e47d5bfaa23235e431c7aa8f8537e3efad5a5ea
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.3.0-py3-none-any.whl

Download URL boilerplate_devops_investigation_agent-0.3.0-py3-none-any.whl
Size 30.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a815954165f551d397c303e86307eeffda122224a59d62fd41958db522424a96
BLAKE2b-256 checksum
How to use checksums
628a6da0b6ffa2823bed1a39dc3f9ba53ccacb7bd84e331b1bb9e46f70296bcb
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.3.0

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