Skip to content

bug: loops, schedule triggers and agent events start a fresh depth-0 chain — an agent can launder its inter-agent chain depth (#2806 follow-up) #2973

Closed

Description

@AndriiPasternak31

Follow-up to #2806.

Defect

#2806 adds an inter-agent chain-depth guard on /chat, /task (parallel, self-task, pull-routed) and /fan-out: an agent-principal call stamps its child chain_depth = 1 + MAX(chain_depth of the caller's running rows) and is refused past inter_agent_max_chain_depth (default 8).

Three other agent-initiated paths still start a new root at depth 0, so an agent near the limit can launder its depth through them:

Path Row creation Today
run_agent_loop → POST /api/agents/{name}/loops services/loop_service.py (triggered_by="loop") iteration rows carry no depth
trigger_schedule → POST /api/agents/{name}/schedules/{id}/trigger scheduler create_schedule_execution row carries no depth
agent-emitted events (POST /api/events) → EVT-001 subscription → /task loopback loopback principal carries vouched_source_agent, not agent_name treated as a root

Each is bounded by something else (loop max_runs/max_cost_usd/max_duration_seconds; the #1578 event-recursion break for agent.task.*), but none by chain depth, so an unbounded tree of chains remains possible.

Acceptance criteria

  1. A loop started by an agent principal stamps its iteration rows with the starter's inherited depth (captured at loop start), and a loop start / schedule trigger / event emit by a caller already at the max is refused with the same named inter_agent_depth_exceeded contract.
  2. Event loopback dispatch derives the caller from vouched_source_agent and inherits its depth.
  3. Tests drive each path through its real entry with a non-default max.
  4. Update the IA-04 "Gaps to fill next" text in docs/testing/orchestration-invariant-catalog.md and requirements/core-agent.md §9.1.1 "Deferred".

Notes

Activity

  1. added
    priority-p3
    type-bug
    theme-reliability
    complexity-medium
    on Sep 22, 2026
  2. added
    status-ready
    priority-p1
    theme-security
    and removed
    priority-p3
    on Sep 27, 2026
  3. vybe commented on Sep 30, 2026

    @vybe
    Contributor

    CSO 2026-09-29 re-framing (Finding 3, HIGH): the loopback-root behaviour this issue tracks is confirmed, but AC #2 (derive the caller from vouched_source_agent and inherit depth) would not bound the attack shape found. get_max_running_chain_depth counts RUNNING rows only, and the loopback POST /task is async, so a serial emit-at-end-of-turn loop reads depth 0 on every hop even with correct attribution — #2806 bounds live nesting, not fan-forward. Self-subscription to any non-agent.task.* event type is allowed (event_subscriptions.py L142-145, pinned by test_1578), the #1578 recursion break covers reserved events only, and there is no per-subscription fire budget, cooldown, event-id dedup or rate limit on emit_event; CapacityFull is swallowed in trigger_subscription. Any agent owner can therefore create an unbounded LLM loop with no platform-side stop.

    Requested changes to this issue:

    • Priority P3 → P1; add theme-security.
    • Add AC: a per-subscription fire budget (Redis INCR+TTL keyed on subscription id; skip dispatch and raise an operator alert on breach) — the only control that bounds the serial loop.
    • Keep AC Feature/gemini runtime support #2 (_chain_caller falls back to vouched_source_agent) for the concurrent case.

    Full trace: docs/security-reports/cso-2026-09-29.md Finding 3.

  4. removed
    status-ready
    on Sep 30, 2026
  5. obasilakis commented on Sep 30, 2026

    @obasilakis
    Contributor

    /claim

  6. added
    status-in-progress
    on Sep 30, 2026
  7. github-actions commented on Sep 30, 2026

    @github-actions

    Claimed by @obasilakis. Label status-in-progress added.

    Next steps:

    1. Create branch: feature/2973-<short-slug>
    2. Implement the feature
    3. Open a PR with Fixes #2973
  8. 2 remaining items

  9. added a commit that references this issue on Sep 30, 2026
  10. added
    status-in-dev
    and removed
    status-in-progress
    on Sep 30, 2026
  11. removed
    theme-reliability
    on Oct 5, 2026
  12. removed
    status-in-dev
    on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

complexity-mediumpriority-p1theme-securitytype-bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions