Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/architecture/context-discipline.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ switches, each read in exactly one place:
| `EGG_SESSION_RESUME` | `egg_agent.session.session_resume_enabled` | Narrower opt-in for warm resume. OFF (default) → a passed-in `session_id` is ignored and the agent cold-starts; the substrate is inert and the agent path is byte-for-byte the legacy cold-start. The master flag above subsumes this: `session_resume_enabled` returns `True` for `EGG_SESSION_RESUME` **or** `context_discipline_enabled()`. |
| `EGG_SESSION_STATE_FILE` | `egg_agent.session.resolve_session_state_path` | Location of the cross-invocation session-state file. Unset → the round-trip is a no-op (substrate stays inert). |
| `EGG_RESEED_THRESHOLD` | `egg_agent.reseed.resolve_reseed_threshold` | Cross-boundary integer override of the reseed threshold. The sandbox runs with `orchestrator` off `PYTHONPATH`, so the orchestrator side may compute `reseed_threshold(model)` and export the integer here; otherwise the gate imports the orchestrator helper when available, and falls back to `None` (safe reseed) when neither yields a value. |
| `EGG_CONTEXT_MEASUREMENT` | `egg_agent.measurement.measurement_enabled` | Opt-in for the emit-only per-event measurement surfaces (#3249). ON (and `EGG_PIPELINE_ID` set) → after each BRC event the agent emits the six context-discipline metrics through the progress + heartbeat surfaces; OFF (default) → the legacy path is byte-identical (no measurement emit). |
| `EGG_REAL_BACKEND_WINDOW` | `egg_agent.measurement._resolve_real_window` | Cross-boundary integer override of the model's real backend window, mirroring `EGG_RESEED_THRESHOLD`. Because `orchestrator` is off `PYTHONPATH` in-pod, this is the channel that populates the window-relative metrics (`real_backend_window` / `window_utilization`) in production; the orchestrator import is a dev/CI-only fallback, and both metrics degrade to `None` when neither yields a value. |

**Slice-9 master flag (`EGG_CONTEXT_DISCIPLINE`, shipped).** The terminal slice
([#3200](https://github.com/jwbron/egg/issues/3200) slice-9) introduced a single
Expand Down
13 changes: 13 additions & 0 deletions shared/egg_agent/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import sys

from egg_agent.client import run_agent
from egg_agent.measurement import record_measurement
from egg_agent.reseed import decide_resume_session
from egg_agent.session import write_session_state

Expand Down Expand Up @@ -113,6 +114,18 @@ def main() -> int:
path=args.session_state_file,
)

# Emit-only per-event measurement (#3249 / #3200 phase 10). Agent-side,
# after the SDK call, routed through the existing progress + heartbeat
# surfaces. Pure observation: the return value is intentionally discarded
# and nothing here touches the exit code — the six metrics are consumed
# offline to tune the route-aware reseed cap. Default OFF behind
# EGG_CONTEXT_MEASUREMENT; a no-op (byte-identical legacy path) otherwise.
record_measurement(
result=result,
resume_decision=resume_decision,
model=args.model,
)

if result.stderr:
print(result.stderr, file=sys.stderr)

Expand Down
Loading
Loading