{
  "format": "agent-article-v0",
  "article_id": "EA-507",
  "canonical_url": "/tools/ea-507-agent-delegation-depth-recursion-guard",
  "page_type": "reference",
  "claim_ids": [],
  "evidence_ids": [
    "EVD-EA-507-URL-29F3AE8BBEDF",
    "EVD-EA-507-URL-E22D8FCD6264",
    "EVD-EA-507-URL-9F9EAB85F625",
    "EVD-EA-507-URL-6984F18D1DFE",
    "EVD-EA-507-URL-FD0584E42BD2",
    "EA-507-CURRENT-APPROVAL",
    "EA-507-CURRENT-BODY-READBACK"
  ],
  "unknown_ids": [
    "EA-507-UNKNOWN-01"
  ],
  "operational_object_ids": [],
  "provider": [],
  "models": [],
  "plans": [],
  "surfaces": [],
  "regions": [],
  "current_status": "CURRENT",
  "observation_status": "SPEC_ONLY",
  "freshness": "CURRENT",
  "last_verified": "2026-10-21",
  "supersedes": [],
  "superseded_by": [],
  "provenance": [
    "EA507-CANDIDATE-20261021-1617JST-C1",
    "SRC-EA-507-URL-29F3AE8BBEDF",
    "SRC-EA-507-URL-E22D8FCD6264",
    "SRC-EA-507-URL-9F9EAB85F625",
    "SRC-EA-507-URL-6984F18D1DFE",
    "SRC-EA-507-URL-FD0584E42BD2",
    "BODY-SHA256:57a5ca53e913cd62dbc851a66e736b04a945a3b06a474cd9ef317c96021d9c2a"
  ],
  "article_sources": [
    {
      "id": "EVD-EA-507-URL-29F3AE8BBEDF",
      "evidence_class": "RESEARCH",
      "title": "OpenAI Agents SDK Python Runner, accessed 2026-10-21:",
      "href": "https://openai.github.io/openai-agents-python/ja/ref/run/",
      "supports": [],
      "limit": "元の監査済み資料に記載された参照先です。URLの復元は、資料の最新性や全主張の支持を新たに検証したことを意味しません。",
      "origin_class": "SOURCE_PACKET_REFERENCE",
      "source_or_experiment_ids": [
        "SRC-EA-507-URL-29F3AE8BBEDF"
      ],
      "supporting_locators": [
        "Source / provenance locators",
        "- OpenAI Agents SDK Python Runner, accessed 2026-10-21: https://openai.github.io/openai-agents-python/ja/ref/run/"
      ],
      "scope": "Source / provenance locators",
      "provenance_status": "SOURCE_PACKET_REFERENCE_PROJECTED"
    },
    {
      "id": "EVD-EA-507-URL-E22D8FCD6264",
      "evidence_class": "RESEARCH",
      "title": "OpenAI Agents SDK JavaScript Running Agents, accessed 2026-10-21:",
      "href": "https://openai.github.io/openai-agents-js/guides/running-agents/",
      "supports": [],
      "limit": "元の監査済み資料に記載された参照先です。URLの復元は、資料の最新性や全主張の支持を新たに検証したことを意味しません。",
      "origin_class": "SOURCE_PACKET_REFERENCE",
      "source_or_experiment_ids": [
        "SRC-EA-507-URL-E22D8FCD6264"
      ],
      "supporting_locators": [
        "Source / provenance locators",
        "- OpenAI Agents SDK JavaScript Running Agents, accessed 2026-10-21: https://openai.github.io/openai-agents-js/guides/running-agents/"
      ],
      "scope": "Source / provenance locators",
      "provenance_status": "SOURCE_PACKET_REFERENCE_PROJECTED"
    },
    {
      "id": "EVD-EA-507-URL-9F9EAB85F625",
      "evidence_class": "RESEARCH",
      "title": "Microsoft Agent Framework Handoff orchestration, accessed 2026-10-21:",
      "href": "https://learn.microsoft.com/en-us/agent-framework/user-guide/workflows/orchestrations/handoff",
      "supports": [],
      "limit": "元の監査済み資料に記載された参照先です。URLの復元は、資料の最新性や全主張の支持を新たに検証したことを意味しません。",
      "origin_class": "SOURCE_PACKET_REFERENCE",
      "source_or_experiment_ids": [
        "SRC-EA-507-URL-9F9EAB85F625"
      ],
      "supporting_locators": [
        "Source / provenance locators",
        "- Microsoft Agent Framework Handoff orchestration, accessed 2026-10-21: https://learn.microsoft.com/en-us/agent-framework/user-guide/workflows/orchestrations/handoff"
      ],
      "scope": "Source / provenance locators",
      "provenance_status": "SOURCE_PACKET_REFERENCE_PROJECTED"
    },
    {
      "id": "EVD-EA-507-URL-6984F18D1DFE",
      "evidence_class": "RESEARCH",
      "title": "A2A Protocol v1.0.1 specification, accessed 2026-10-21:",
      "href": "https://a2a-protocol.org/v1.0.1/specification/",
      "supports": [],
      "limit": "元の監査済み資料に記載された参照先です。URLの復元は、資料の最新性や全主張の支持を新たに検証したことを意味しません。",
      "origin_class": "SOURCE_PACKET_REFERENCE",
      "source_or_experiment_ids": [
        "SRC-EA-507-URL-6984F18D1DFE"
      ],
      "supporting_locators": [
        "Source / provenance locators",
        "- A2A Protocol v1.0.1 specification, accessed 2026-10-21: https://a2a-protocol.org/v1.0.1/specification/"
      ],
      "scope": "Source / provenance locators",
      "provenance_status": "SOURCE_PACKET_REFERENCE_PROJECTED"
    },
    {
      "id": "EVD-EA-507-URL-FD0584E42BD2",
      "evidence_class": "RESEARCH",
      "title": "A2A Protocol v1.0.1 specification, accessed 2026-10-21:",
      "href": "https://a2a-protocol.org/",
      "supports": [],
      "limit": "元の監査済み資料に記載された参照先です。URLの復元は、資料の最新性や全主張の支持を新たに検証したことを意味しません。",
      "origin_class": "SOURCE_PACKET_REFERENCE",
      "source_or_experiment_ids": [
        "SRC-EA-507-URL-FD0584E42BD2"
      ],
      "supporting_locators": [
        "Source / provenance locators",
        "- A2A Protocol v1.0.1 specification, accessed 2026-10-21: https://a2a-protocol.org/"
      ],
      "scope": "Source / provenance locators",
      "provenance_status": "SOURCE_PACKET_REFERENCE_PROJECTED"
    },
    {
      "id": "EA-507-CURRENT-APPROVAL",
      "evidence_class": "RESEARCH",
      "title": "現行本文の監査・revision対応",
      "supports": [
        "現行台帳のAUDIT_PASSと候補・revision・本文ハッシュの対応を確認しています。"
      ],
      "limit": "監査状態と来歴の記録です。外部根拠の最新性や本文の全主張を追加保証しません。",
      "origin_class": "AUDITED_CANONICAL_RESEARCH_PACKET",
      "source_or_experiment_ids": [
        "EA507-CANDIDATE-20261021-1617JST-C1"
      ],
      "supporting_locators": [
        "1KqhJtiSb2S84rWmeYVwKcT_76dBwZ_B0ZZuAWQqH0rQ/EA_REVISION_LEDGER#ea_id=EA-507&revision_id=EA-507-RESEARCH-20261021-R1&candidate_id=EA507-CANDIDATE-20261021-1617JST-C1",
        "EA-507-RESEARCH-20261021-R1"
      ],
      "provenance_status": "CURRENT_CANONICAL_APPROVAL_READBACK"
    },
    {
      "id": "EA-507-CURRENT-BODY-READBACK",
      "evidence_class": "IMPL",
      "title": "現行本文の収録照合",
      "supports": [
        "公開生成入力の本文SHA-256が、監査済み候補に結び付いたハッシュと一致しています。"
      ],
      "limit": "本文の同一性の検査です。外部システムの挙動や全主張の真偽を実証したものではありません。",
      "checked_at": "2026-10-22",
      "origin_class": "IMPLEMENTATION_READBACK",
      "source_or_experiment_ids": [
        "BODY-SHA256:57a5ca53e913cd62dbc851a66e736b04a945a3b06a474cd9ef317c96021d9c2a"
      ],
      "supporting_locators": [
        "content/staging/EA-507.md",
        "57a5ca53e913cd62dbc851a66e736b04a945a3b06a474cd9ef317c96021d9c2a",
        "EA-507-RESEARCH-20261021-R1"
      ],
      "provenance_status": "CURRENT_APPROVED_BODY_HASH_MATCH"
    }
  ],
  "research_sections": [
    {
      "heading": "要点と前提",
      "text": "Agentが別Agentへ仕事を委譲できる構成では、個々のhandoffが正当でも、A→B→A、A→B→C→Aのようなcycleや、sub-agentがさらにsub-agentを生成する連鎖によって、turn数・token・tool call・外部副作用・待ち時間が上限なく増えることがあります。対策は単一の「再帰回数」だけではなく、run全体へ伝播するdelegation budget、visited-edge/cycle detection、per-agent turn limit、wall-clock/deadline、side-effect budget、明示的termination conditionを組み合わせることです。"
    },
    {
      "heading": "主要claim",
      "text": "OpenAI Agents SDKのRunnerは、final outputが出るまでagent invocation、handoff、tool callをloopし、`max_turns` でrunの最大turn数を制限できます。現行Python SDK文書ではturnを1回のAI invocationとして定義し、上限超過時は `MaxTurnsExceeded` になります。JavaScript SDKも `maxTurns` を安全上の上限として持ちます。これは無限loopを止める実装上のguardですが、handoff depthそのもの、外部API call数、token/cost、business side effect数を個別に保証する契約ではありません。\n\nMicrosoft Agent Frameworkのhandoff orchestrationは、agent間のhandoff ruleを明示でき、autonomous modeではtermination conditionまたはper-agent turn limitまで継続します。現行文書ではautonomous modeにper-agent turn limitがあり、defaultは各agent 50 autonomous turnsです。したがってframeworkがloop guardを持つ例はありますが、複数agentを跨ぐ総delegation budgetやbusiness-side-effect budgetは別途設計する必要があります。\n\nA2Aはagent間のinteroperabilityとtask lifecycleを定義し、agentが別agentへtaskを委譲・協調できる通信層です。一方、公式文書はA2Aをsub-agent/tool-call protocolではないと明記しています。したがってA2Aを使うだけで内部delegation depth、cycle、budget propagationが自動的に制御されるとは扱いません。"
    },
    {
      "heading": "運用上の意味・failure",
      "text": "### Handoff cycle\n\nhandoff graphにA→BとB→Aが許可されていると、model判断だけで相互移譲を反復する可能性があります。各handoffがschema上validでも、goal progressが無ければloopです。agent名だけでなく、`(source_agent, target_agent, task_fingerprint)` の反復や、同一subgoalの再委譲を検出します。\n\n### Depthだけでは止まらない\n\n最大depth=3でも、各階層で多数のsiblingsを生成できればfan-outでwork量は増えます。逆に総turn数だけを制限すると、正当な深いworkflowを早期停止することがあります。depth、total delegations、concurrent children、model turns、tool calls、tokens/cost、wall-clockを別budgetとして扱います。\n\n### Budget reset\n\n親から子へ委譲するときに子が新しいrunとして初期budgetを得る設計では、再帰的委譲で上限を迂回できます。root operationのbudgetをauthoritativeに持ち、childへ「残量」を継承します。child local limitとroot global limitを分離し、より厳しい方で停止します。\n\n### Cancellation propagation\n\n親runがdeadlineやbudget超過で停止しても、既にremote agentやtoolへ送ったtaskが継続する場合があります。停止条件は新規delegation禁止だけでなく、outstanding childのcancel要求、結果無視、reconciliation、必要なcompensationまで含めます。cancel requestedをexternal effect canceledと同一視しません。\n\n### Hidden recursion\n\nA2Aのようなopaque remote agentでは、remote側が内部で何段sub-agentを使ったかclientから見えないことがあります。client側の「depth=1」はremote内部の計算量を意味しません。契約できるのは自分が発行するremote task数、deadline、quota、cost、response size等の観測可能な境界です。"
    },
    {
      "heading": "具体的control / implementation implication",
      "text": "### 1. Root delegation context\n\nroot operationに次を持たせ、handoff/subtask作成時に継承します。\n\n- `root_operation_id`\n- `parent_operation_id`\n- `delegation_depth`\n- `delegations_used / delegations_limit`\n- `model_turns_used / model_turns_limit`\n- `tool_calls_used / tool_calls_limit`\n- `concurrent_children / child_limit`\n- `deadline_at`\n- `token_or_cost_budget`\n- `side_effect_budget`\n- `visited_delegation_edges` またはcycle-detection用fingerprint\n\nframework固有のcontext object、workflow state、durable store等へ置けますが、childが勝手にbudgetを再初期化できないauthoritative sourceを持たせます。\n\n### 2. Pre-delegation gate\n\n新しいhandoff/subtaskを作る直前に、depth、残budget、deadline、同時child数、cycle、target allowlist、side-effect riskを判定します。上限超過時は「別agentへ投げ直す」のではなく、現在までの結果をまとめる、human escalationへ送る、bounded failureとして終了する、のいずれかへ遷移します。\n\n### 3. Cycle detection\n\n単純なagent-name visited setだけでは、A→B→Aでも別subgoalなら正当な場合があります。最低でもagent edgeとtask/subgoal fingerprintを組み合わせ、同一目的の反復を検出します。false positiveを避けるため、cycle検出時に即failureとせず、残budget、progress signal、成果差分を併用できます。\n\n### 4. Termination condition\n\n「モデルが終了を選ぶ」以外に機械的terminationを持たせます。例として、max turns、deadline、budget exhaustion、no-progress count、duplicate subgoal、required artifact completion、human approval待ち等があります。Microsoft Agent Frameworkのautonomous handoffがtermination conditionとper-agent turn limitを持つこと、OpenAI Agents SDKがmax turnsを持つことは、この種のguardをruntimeへ置く具体例です。\n\n### 5. Side-effect separation\n\nread-only調査Agentとwrite/action Agentでbudgetを分けます。多数のdelegationを許しても、payment/send/delete/deploy等の不可逆または高risk actionは別のapproval・idempotency・quotaを要求します。delegation budgetはside-effect safetyの代替ではありません。\n\n### 6. Observability\n\n少なくともroot operationごとに、handoff graph、depth、fan-out、turns、tool calls、elapsed time、cost/token、termination reason、cycle-detection hit、outstanding childを記録します。p95/p99のdepth・delegation countと、budget exhaustion率、同一edge反復、cancel後残存childを監視します。\n\n### 7. Evaluation\n\n正常系だけでなく、A↔B ping-pong、三角cycle、fan-out爆発、child budget reset、remote timeout、parent cancel後のchild継続、同一subgoal表現ゆれを含むfailure testを作ります。上限到達時に新しい副作用が発生しないこと、partial resultまたは明示的failureへ収束することを確認します。"
    },
    {
      "heading": "適用境界",
      "text": "OpenAI Agents SDKの `max_turns` / `maxTurns` はSDK run loopの上限です。これを「delegation depth上限」「tool call総数上限」「cost上限」と読み替えません。SDK versionやlanguage implementationでdefaultやerror handlingは変わり得るため、利用versionの文書を固定します。\n\nMicrosoft Agent Frameworkのper-agent turn limitはhandoff autonomous modeの具体的runtime behaviorであり、他frameworkへ一般化しません。またper-agent limitはroot全体のglobal budgetと同義ではありません。\n\nA2Aはremote agent間のtask/message protocolです。remote agent内部のsub-agent recursionをclientが完全観測できるとは限りません。protocol task ID、state、cancel等で見える範囲と、remote implementation内部を分離します。"
    },
    {
      "heading": "Counterevidence / limitations",
      "text": "厳しいdepth/turn上限はrunawayを止めますが、長い正当workflowも切断します。固定値を安全性の唯一基準にすると、複雑なincident response、調査、承認workflowでfalse terminationが増えます。budget exhaustionを単なるerrorではなく、partial-result返却やhuman escalationへ接続する必要があります。\n\ncycleは常に異常ではありません。reviewer→author→reviewerの反復や、triage→specialist→triageのhandoffは正当な反復です。cycle detectionは「同じnodeを再訪した」だけでなく、progress、subgoal、iteration count、termination criteriaを考慮します。\n\nremote agentがopaqueな場合、client側budgetはremote内部computeを直接制限できません。provider quota、deadline、billing cap、contract、remote側policyが必要です。"
    },
    {
      "heading": "OPEN_UNKNOWN",
      "text": "- 対象業務で許容すべき最大delegation depth、fan-out、total turns、tool calls、wall-clockの値。\n- subgoal fingerprintをどの粒度で同一と判定すべきか。\n- remote A2A agentが内部delegation budgetを受け入れ、強制できる標準的な方法。\n- parent cancellation後にremote childが継続した場合のreconciliation/compensation契約。\n- token/cost budgetとside-effect risk budgetを同一root contextでどう整合させるか。\n- human-in-the-loopの待機時間をdeadline budgetへ含めるか除外するか。"
    },
    {
      "heading": "SAFE_WORDING",
      "text": "「max turnsを設定すれば再帰問題は解決する」「A2Aがdelegation cycleを防止する」とは断定しません。安全な表現は、「agent delegationにはdepth、fan-out、turn/tool/cost/deadline、cycle/no-progress、side-effectを別々のbudgetとして持たせ、root operationからchildへ残量を継承し、機械的terminationとcancellation/reconciliationを設ける。frameworkのmax-turn機能はその一部であり、remote agent内部やbusiness side effectまで自動保証するものではない」です。"
    },
    {
      "heading": "Source / provenance locators",
      "text": "- OpenAI Agents SDK Python Runner, accessed 2026-10-21: https://openai.github.io/openai-agents-python/ja/ref/run/\n- OpenAI Agents SDK JavaScript Running Agents, accessed 2026-10-21: https://openai.github.io/openai-agents-js/guides/running-agents/\n- Microsoft Agent Framework Handoff orchestration, accessed 2026-10-21: https://learn.microsoft.com/en-us/agent-framework/user-guide/workflows/orchestrations/handoff\n- A2A Protocol v1.0.1 specification, accessed 2026-10-21: https://a2a-protocol.org/v1.0.1/specification/\n- A2A Protocol overview / framework boundary, accessed 2026-10-21: https://a2a-protocol.org/"
    }
  ],
  "human_url": "/tools/ea-507-agent-delegation-depth-recursion-guard",
  "markdown_url": "/agent/article.md?path=%2Ftools%2Fea-507-agent-delegation-depth-recursion-guard",
  "json_url": "/agent/article.json?path=%2Ftools%2Fea-507-agent-delegation-depth-recursion-guard"
}