Repository navigation
Expand file tree
/
Copy pathenvelope.py
More file actions
58 lines (45 loc) · 2.53 KB
/
Copy pathenvelope.py
File metadata and controls
58 lines (45 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
"""Invocation envelope and response models for the AgentCore entrypoint."""
from __future__ import annotations
from typing import Literal
from pydantic import BaseModel, ConfigDict, Field
from agent.domain.correlation import CorrelationContext
from agent.domain.events import NormalizedJiraEvent
InvokeStatus = Literal["processed", "skipped", "duplicate", "error"]
class InvokeEnvelope(BaseModel):
"""Strict envelope passed to the agent runtime instead of a free-text prompt."""
model_config = ConfigDict(extra="forbid", frozen=True)
thread_id: str = Field(min_length=1)
correlation: CorrelationContext
event: NormalizedJiraEvent
checkpoint_ns: str | None = Field(default=None)
class InvokeResponse(BaseModel):
"""Response shape returned by the AgentCore entrypoint."""
model_config = ConfigDict(extra="forbid")
status: InvokeStatus
correlation_id: str = Field(min_length=1)
issue_key: str | None = Field(default=None)
skipped_reason: str | None = Field(default=None)
error: str | None = Field(default=None)
# Wave 5: machine-readable error category (e.g. ``"guardrail_blocked"``)
# so operators / dashboards can route on the cause without parsing the
# free-form ``error`` string. ``None`` for non-error responses.
error_type: str | None = Field(default=None)
decision: str | None = Field(default=None)
rendered_comment: str | None = Field(default=None)
# M5.9: per-request MCP retry count, populated by the
# graph's persist node from the request-scoped observer. ``None``
# for skip / duplicate / signature-failure paths where no MCP call
# was issued; ``0`` for happy paths where every call succeeded on
# the first attempt. The webhook handler emits this on the
# ``webhook.processed`` structured-log line so retries are
# graphable from the log feed even when OTel is disabled locally.
mcp_retry_count: int | None = Field(default=None, ge=0)
# Wave 9: end-to-end duration in milliseconds (signature → normalize
# → idempotency → recursion → graph → persist). Populated by the
# ``WebhookHandler`` on every terminal response (skipped / duplicate
# / processed / error) so the integration-tier perf test can compute
# p95 / p99 budgets without pulling the OTel histogram out of the
# AgentCore Runtime. ``None`` only for direct envelope invocations
# that bypass ``WebhookHandler.handle`` — in that case the caller
# already knows the wall-clock cost.
duration_ms: float | None = Field(default=None, ge=0.0)