feat(28-02): structured JSON failure telemetry + CLI fallback size guards#12
Open
OgeonX-Ai wants to merge 2 commits into
Open
feat(28-02): structured JSON failure telemetry + CLI fallback size guards#12OgeonX-Ai wants to merge 2 commits into
OgeonX-Ai wants to merge 2 commits into
Conversation
…ack and cap CLI subprocess size - Add maf_starter/telemetry.py with emit_failure_telemetry(event, **fields), a stdlib-only, non-raising helper that writes one line of parseable JSON to stderr so failures are observable to log-based monitoring, not just in-memory response metadata. - Wire emit_failure_telemetry into provider_fallback.py's fallback_middleware and _wrap_stream_with_fallback at four points: primary-provider failure, each fallback step failure, fallback success/recovery, and full-chain exhaustion, in both the non-streaming and streaming code paths. - Add MAX_CLI_OUTPUT_BYTES and MAX_CLI_PROMPT_BYTES (1MB, mirroring loop_worker_cli.py's existing MAX_REQUEST_BYTES convention) and enforce them in _run_subprocess and _messages_to_prompt, closing the remaining C6 gap on the CLI-fallback subprocess path. - Add tests/test_provider_fallback_telemetry.py: parseable single-line JSON contract, non-raising stderr-write-failure behavior, ordered telemetry events for chain exhaustion vs. fallback recovery, and size-limit rejection tests for both new constants.
… task failures
- Call emit_failure_telemetry("worker_task_failed", run_id=run_id,
error=str(exc)) inside WorkerBoundary._run's existing except block,
alongside the existing self._status[run_id] = f"error:{exc}" assignment,
so background workflow failures are visible to log-based monitoring
instead of only an in-memory status dict polled via get_status.
- Existing status-string contract (get_status/is_done semantics) is
unchanged; only the additional telemetry call was added.
- Extend tests/test_worker_boundary.py's error-path test to capture stderr
and assert the emitted worker_task_failed telemetry line is parseable
JSON containing run_id and error.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
maf_starter/telemetry.py::emit_failure_telemetry— a stdlib-only, non-raising helper that writes one line of parseable JSON to stderr, closing the REQ-1.4.3 gap where provider-fallback and worker-boundary failures were only visible via in-memory state.provider_fallback.py'sfallback_middlewareand_wrap_stream_with_fallback(primary failure, per-fallback-step failure, fallback success, chain exhaustion — both streaming and non-streaming paths) and intoworker_boundary.py'sWorkerBoundary._run(worker_task_failed).MAX_CLI_OUTPUT_BYTES/MAX_CLI_PROMPT_BYTES(1MB, matchingloop_worker_cli.py's existingMAX_REQUEST_BYTESconvention) and enforces them in_run_subprocess/_messages_to_prompt.Test plan
python -m pytest tests/test_provider_fallback_telemetry.py tests/test_worker_boundary.py -v— 16/16 passedpython -m pytest tests/(full suite) — 134 passed, 1 skipped, no regressionsrate limitmarker) proves ordered, parseable JSON telemetry for both the chain-exhaustion path and the fallback-recovery pathNothing merged; PR only, no branch protection touched.