Public report of openai/openai-agents-python, published 4 November 2026. It has the same score, grades and number of findings as the full report. The details of security findings (where they are in the code, which known vulnerabilities and which passwords or keys were found) are left out, so nobody can use them against the project.
Public
Executive report Measured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.11.2). Assert signed this survey and filed it in the standard's public register, where anyone can look it up by its survey ID. Check this survey → Signed and filed in the standard's public register, 4 November 2026, 04:16 UTC · Survey ID cd_03325f2d5bbc49c9b7812a3b7b1347a8

openai/openai-agents-python

Measured 4 November 2026, 04:15 UTC, at code version 23e9996

CAI score 67out of 100 At risk Up 8 since the last survey

The score is built from these lenses. Each lens grades one area of the code, such as how easy it is to change or how well it is protected. The weakest lens counts most, so one weak area pulls the score down instead of being averaged away.

A large codebase: 146,511 lines of product code in 2 projects, tests not counted · Estimated rebuild effort: about 3.4 person-years · Weakest lens: Domain Modelling, 54

Findings by how serious they are

4 critical 752 serious 59 minor

17 dimensions are left out of the score. For each one, we either couldn't measure it in this code, or found no evidence of the safeguard we look for, such as a tested backup restore. They count neither for nor against the score, and Limitations lists each one with its reason.

This survey was produced by

Assert small markCanine Code Analyzer
Producer
Canine Development
Analyzer
Canine Code Analyzer engine 1.0.0
Measured
4 November 2026, 04:15 UTC

A measurement, not a certificate. The Code Assurance Index records a number together with the evidence it was worked out from, so anyone can recalculate it, but it doesn't certify or guarantee the code. The standard was written by Canine Development, which also builds the Canine Code Analyzer. It is open to any tool that implements it, and today the Canine Code Analyzer is the only one that does.

A critical security finding is open, such as a library with a known critical vulnerability or a password or key found in the code. The score itself is unchanged, but its band shows At risk until the finding is fixed. See the Security and Compliance lens.

The score is deterministic, which means the same code always gets the same score. We work it out with tools that follow published rules, and an AI model never decides it, so anyone who applies the same rules to the same code gets the same number. How it is done is explained under Methodology ▸

57of 57 dimensions measured by tools.
809of 815 findings point to an exact file and line, so you can open each one in the code. The other 6 concern the repository as a whole, such as missing documentation.
57dimensions across 7 lenses, read from 146,511 lines of product code in 2 projects.
Chapters

Executive summary

openai/openai-agents-python is rated At risk because critical security findings are open, all of them in the packages it uses. It scores 67 out of 100, which the At risk rating leaves unchanged. We judged it as a preview release, against a lower bar.

Domain Modelling, at 54, is the weakest lens and counts most in the score. The best first step is moving database and web code out of the business core, worth about 11 points. Raising Domain Modelling to 65 would lift the score to about 72.

Three known security holes in the packages the code depends on can be used by attackers. Updating the vulnerable packages would close this risk.

The product code is 146,511 lines, about €500,000 to rebuild.

A lens is capped at Adequate while one of its dimensions scores below 4 out of 10, however well the rest of the lens does. That way a serious problem in one place always shows in the lens's rating.

How the score is built: what each lens counts for The lenses don't count equally. The weakest lens counts most, the next weakest a little less, and so on, so a weak area pulls the score down instead of being averaged away. In the bar below, each part's width shows how much that lens counts and its colour shows its rating. Improving the widest part moves the score most, and as that lens improves, it counts for less, because another lens becomes the weakest.
Domain Modelling 54 · counts for 46%Code Health 74 · counts for 25%Maturity 76 · counts for 14%Production Readiness 81 · counts for 8%Architecture 89 · counts for 4%Security and Compliance 91 · counts for 2%Performance 100 · counts for 1%

If Domain Modelling rose from 54 to 65, the lowest score rated Strong, the score would rise from 67 to about 72.

Code composition: what the lines of code are
Product code 36%Tests 64%
New since the last survey: 6 findings

These 6 critical or serious findings weren't in the previous survey, on 20 October 2026.

We compare every finding with the previous survey's. A finding that has only moved to another line in the same file counts as the same finding, so only new findings appear here. Advisory notes from the AI model are left out, because the model words them afresh in every survey.

Fixed since the last survey: 60 findings

These 60 critical or serious findings were in the previous survey, on 20 October 2026, and are gone from this one.

  • Churn × Complexity Hotspots · Hotspot: src/agents/tool.py src/agents/tool.py
  • Churn × Complexity Hotspots · Hotspot: src/agents/tracing/provider.py src/agents/tracing/provider.py
  • Churn × Complexity Hotspots · Hotspot: examples/realtime/app/server.py examples/realtime/app/server.py
  • Churn × Complexity Hotspots · Hotspot: src/agents/extensions/tool_output_trimmer.py src/agents/extensions/tool_output_trimmer.py
  • Churn × Complexity Hotspots · Hotspot: src/agents/realtime/audio_formats.py src/agents/realtime/audio_formats.py
  • Churn × Complexity Hotspots · Repeated repair: src/agents/run_internal/guardrails.py src/agents/run_internal/guardrails.py
  • Churn × Complexity Hotspots · Repeated repair: src/agents/extensions/memory/dapr_session.py src/agents/extensions/memory/dapr_session.py
  • Churn × Complexity Hotspots · Repeated repair: src/agents/util/_error_tracing.py src/agents/util/_error_tracing.py
  • Churn × Complexity Hotspots · Repeated repair: src/agents/extensions/sandbox/blaxel/mounts.py src/agents/extensions/sandbox/blaxel/mounts.py
  • Churn × Complexity Hotspots · Repeated repair: src/agents/util/_pretty_print.py src/agents/util/_pretty_print.py
  • Churn × Complexity Hotspots · Repeated repair: src/agents/sandbox/session/manager.py src/agents/sandbox/session/manager.py
  • Churn × Complexity Hotspots · Repeated repair: src/agents/realtime/handoffs.py src/agents/realtime/handoffs.py
  • Dependency Vulnerabilities · High vulnerability: [GHSA redacted] REDACTED
  • Dependency Vulnerabilities · Medium CVE: [GHSA redacted] REDACTED
  • Exception handling · Swallowed exception (empty catch) src/agents/extensions/experimental/codex/output_schema_file.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/extensions/experimental/codex/codex_tool.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/extensions/experimental/codex/codex_tool.py
  • Exception handling · Swallowed exception (empty catch) src/agents/extensions/memory/redis_session.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/extensions/memory/redis_session.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/extensions/memory/mongodb_session.py
  • Exception handling · Swallowed exception (empty catch) src/agents/extensions/memory/mongodb_session.py
  • Exception handling · Swallowed exception (empty catch) src/agents/extensions/memory/mongodb_session.py
  • Exception handling · Swallowed exception (empty catch) src/agents/extensions/memory/mongodb_session.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/extensions/memory/mongodb_session.py
  • Exception handling · Swallowed exception (empty catch) src/agents/extensions/memory/encrypt_session.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/extensions/memory/dapr_session.py
  • Exception handling · Swallowed exception (empty catch) src/agents/extensions/memory/async_sqlite_session.py
  • Exception handling · Swallowed exception (empty catch) src/agents/extensions/memory/async_sqlite_session.py
  • Exception handling · Swallowed exception (empty catch) src/agents/extensions/memory/advanced_sqlite_session.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/extensions/memory/advanced_sqlite_session.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/extensions/models/litellm_model.py
  • Exception handling · Swallowed exception (empty catch) REDACTED
  • Exception handling · Swallowed exception (empty catch) src/agents/mcp/server.py
  • Exception handling · Swallowed exception (empty catch) src/agents/mcp/server.py
  • Exception handling · Swallowed exception (empty catch) src/agents/mcp/server.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/memory/sqlite_session.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/memory/session.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/memory/session.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/memory/session.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/models/openai_responses.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/models/openai_responses.py
  • Exception handling · Swallowed exception (empty catch) src/agents/models/openai_responses.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/realtime/session.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/realtime/openai_realtime.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/turn_resolution.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/turn_resolution.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/tool_planning.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/run_loop.py
  • Exception handling · Swallowed exception (empty catch) src/agents/run_internal/run_loop.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/run_loop.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/run_loop.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/run_grouping.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/oai_conversation.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/oai_conversation.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/items.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/items.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/items.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/items.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/items.py
  • Exception handling · Swallowed exception (caught, then discarded) src/agents/run_internal/items.py
Rebuild cost: about €500,000 · Estimate
Cost to rebuild€160,000 to €830,000, for 2,742 to 8,700 hours of work, about 3.4 person-years for 2 to 7 engineers
Difficulty of the problemStandard, judged from the kind of software and how it is built. Code that solves a harder problem, such as payments or medical bookings, costs more per line to write.
Quality factor×0.9 at a score of 67. Better code takes more work to write, so the factor is ×1.0 at a score of 70, lower below it and higher above it.
SizeLarge: 146,511 lines of product code
What it is notNot a quotation: nobody has offered to build it for that. Not a valuation: it says nothing about what the business is worth. Not a certified figure: no professional has signed it as one.

How the estimate is made: We price the hours a team would need to write this code again, at €60 to €95 an hour. Declarations and boilerplate are priced at a fast rate and logic at a slower one, and the logic is then multiplied by the difficulty of the problem and by the quality factor. The estimate can be about 30% off either way, and it moves most with the hourly rate and the difficulty. For this code, every line is priced as straight logic, which keeps the estimate on the low side.

Top priorities

The three actions that raise the score most for the work they take. The full ranked list is in the Roadmap.

1
Keep the ORM/table mapping on a boundary data-model + mapper; leave the domain entity framework-free (map row↔domain through a repository).
Raises the score by about 11 points · Medium effort · Domain ↔ infrastructure boundary
2
Swallowed exception (caught, then discarded)
Raises the score by about 2 points · Medium effort · Exception handling
3
Record your significant design decisions.
Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
Raises the score by about 1 point · Medium effort · Architecture documentation

Diagnosis: what the measurements show together

Each conclusion below combines several dimensions into one point that no single dimension shows, and lists the measurements it rests on.

Where the investment is most exposed · Value at risk
This code would cost about €500,000 to build again, about 3.4 person-years of work. Its weakest lens is Domain Modelling, at 54 (Adequate). Domain Modelling is about whether the code protects the rules the business depends on. Because the weakest lens counts most in the score, work on Domain Modelling also moves the score most.
Based on: the rebuild estimate · the Domain Modelling grade · how much each lens counts
What to do: Start with the Domain Modelling actions in Top priorities.
If you do one thing first · First action
Keep the ORM/table mapping on a boundary data-model + mapper; leave the domain entity framework-free (map row↔domain through a repository). Of all the actions in this report, it raises the score most for the work it takes: about 11 points for medium effort. The next survey will show the change in the score.
Based on: the ranked actions in Top priorities, by score gain and effort
What hard-to-read code costs each year · Cost
Four dimensions measure how easy the code is to work in: two measure how tangled its logic is, one how much of it is copied, and one how well each part sticks to a single job. In this codebase they average 6.1 out of 10. Code at that level is slower to change than clean code, and we estimate the extra work at 5% to 11% on every change. The history of the code shows how much it changes: about 259,785 lines over the last 90 days, which is about 1,053,572 lines a year. At that pace, the extra work comes to an estimated 127.9 to 767.5 engineer-days a year, and it grows as more code changes.
How this is estimated: The number of changed lines is measured from the history of the code. The rest rests on two assumptions of our own: code scoring 8 out of 10 or more adds no extra work, and each point below 8 adds 2.5% to 5.6% to every change, never less than 2% to 5% and never more than 40% to 60% in all; and an engineer changes 150 to 400 lines in a day. The result is a range for planning, not a measurement.
Based on: Cyclomatic Complexity · Cognitive Complexity · Code Duplication · Cohesion (LCOM4) · the code's change history
What to do: Start with the files listed under Churn × Complexity Hotspots, which change often and are hard to read, because that is where the extra work is paid most often.

Architecture: which parts of the code depend on which

The code is divided into modules, groups of code that each handle one part of the product, and a module depends on another when it uses code from it. The table lists the modules both down the side and across the top, in an order where each module should only use modules listed above it. A number in a cell means the module on that row uses the module in that column, and it counts the pairs of building blocks (types) that connect them. The one thing to look for is a mark above the diagonal line. It means two or more modules use each other in a loop (a dependency cycle), so none of them can be changed, tested or released on its own.

155 modules, with 225 dependencies between them. One loop runs through 2 of the modules, marked above the diagonal.

The table shows the 40 modules with the most connections; 115 more are left out to keep it readable.

Which modules use which. The module on each row uses the module in each column, and the number counts the pairs of types that connect them. A cell above the diagonal is part of a loop.
uses →1 exceptions2 extensions.experimental.codex.thread3 memory.session4 model_settings5 realtime.config6 realtime.model7 result8 retry9 tool10 tracing.processor_interface11 usage12 voice.input13 _function_tool_arguments14 agent15 extensions.experimental.codex16 items17 realtime.model_events18 tracing.traces19 voice.model20 mcp.util21 models.interface22 realtime.agent23 realtime.openai_realtime24 run_context25 run_internal.run_steps26 extensions.models.any_llm_model27 extensions.models.litellm_model28 mcp.server29 models30 models.openai_chatcompletions31 models.openai_responses32 realtime.session33 run_config34 run_state35 testing.model36 tracing37 src.agents38 responses_websocket_session39 run_internal.tool_execution40 run_internal
1 exceptions
2 extensions.experimental.codex.thread
3 memory.session
4 model_settings
5 realtime.config
6 realtime.model
7 result
8 retry
9 tool
10 tracing.processor_interface
11 usage
12 voice.input
13 _function_tool_arguments1
14 agent111
15 extensions.experimental.codex111
16 items1
17 realtime.model_events1
18 tracing.traces1
19 voice.model2
20 mcp.util121
21 models.interface111
22 realtime.agent1
23 realtime.openai_realtime151
24 run_context11
25 run_internal.run_steps61
26 extensions.models.any_llm_model1112
27 extensions.models.litellm_model1112
28 mcp.server111
29 models12211
30 models.openai_chatcompletions1112
31 models.openai_responses22112
32 realtime.session1221231
33 run_config1
34 run_state112
35 testing.model21213
36 tracing131
37 src.agents223111112
38 responses_websocket_session21
39 run_internal.tool_execution121
40 run_internal213333311826821
Uses a module listed above itPart of a loopThe module itself
1 exceptions2 extensions.experimental.codex.thread3 memory.session4 model_settings5 realtime.config6 realtime.model7 result8 retry9 tool10 tracing.processor_interface11 usage12 voice.input13 _function_tool_arguments14 agent15 extensions.experimental.codex16 items17 realtime.model_events18 tracing.traces19 voice.model20 mcp.util21 models.interface22 realtime.agent23 realtime.openai_realtime24 run_context25 run_internal.run_steps26 extensions.models.any_llm_model27 extensions.models.litellm_model28 mcp.server29 models30 models.openai_chatcompletions31 models.openai_responses32 realtime.session33 run_config34 run_state35 testing.model36 tracing37 src.agents38 responses_websocket_session39 run_internal.tool_execution40 run_internalexceptions1extensions.experimental.codex.thread2memory.session3model_settings4realtime.config5realtime.model6result7retry8tool9tracing.processor_interface10usage11voice.input12_function_tool_arguments13agent14extensions.experimental.codex15items16realtime.model_events17tracing.traces18voice.model19mcp.util20models.interface21realtime.agent22realtime.openai_realtime23run_context24run_internal.run_steps25extensions.models.any_llm_model26extensions.models.litellm_model27mcp.server28models29models.openai_chatcompletions30models.openai_responses31realtime.session32run_config33run_state34testing.model35tracing36src.agents37responses_websocket_session38run_internal.tool_execution39run_internal4011111111112121111115111611112111211112211111222112122123111122121313122311111221121213333311826821+115 more modules (most-connected shown)

At a glance — Code Health · 74% · Adequate · gated by D1, D2 ·

At a glance — Architecture · 89% · Adequate · gated by D26 ·

At a glance — Maturity · 76% · Strong ·

At a glance — Readiness · 81% · Strong ·

At a glance — Security · 91% · Exemplary ·

At a glance — Domain Modelling · 54% · Adequate ·

At a glance — Performance · 100% · Exemplary ·

Security & Compliance — OWASP Top-10 mapping

Findings mapped to OWASP categories; the specific CVEs/secrets are in the Security dimension cards below and findings.md (redacted only on the public version of this report).

OWASP categoryFindingsSeverity
A05:2025 — Injection11Medium
A03:2025 — Software Supply Chain Failures5High / Critical

Roadmap

Top priorities: Keep the ORM/table mapping on a boundary data-model + mapper; leave the domain entity framework-free (map row↔domain through a repository); Swallowed exception (caught, then discarded); Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.

Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.

Do thisHelpsEffortDimension
Keep the ORM/table mapping on a boundary data-model + mapper; leave the domain entity framework-free (map row↔domain through a repository).+11.4 ptsMediumDomain ↔ infrastructure boundary
Swallowed exception (caught, then discarded)+1.5 ptsMediumException handling
Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.+1.3 ptsMediumArchitecture documentation
Bring the 8 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with AgentRunner._run_impl (cyclomatic 239), run_loop.start_streaming (cyclomatic 201), turn_resolution.resolve_interrupted_turn (cyclomatic 170).+1.1 ptsHighCyclomatic Complexity
Resolve the 1 Off-boarding risk finding(s) in Bus Factor.+0.5 ptsLowBus Factor
Bring the 31 bodies over 60 down to 60 or less in Cognitive Complexity — start with AgentRunner._run_impl (cognitive 609), run_loop.start_streaming (cognitive 474), ChatCmplStreamHandler.handle_stream (cognitive 319).+0.8 ptsHighCognitive Complexity
Resolve the 37 FileTooLong finding(s) in God Classes — start with model.py (2), items.py (2), run_state.py.+0.6 ptsHighGod Classes
Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion.+0.3 ptsLowProject Cohesion

File quality

Per-file score 0–10 — a quality signature. Of 150 files carrying findings, judged against the Preview bar: 0% slop · 6% mixed · 94% near-clean.

FileScoreBandWorst signal
REDACTED5.1MixedDependency Vulnerabilities: Critical CVE: REDACTED
REDACTED5.3MixedStatic Analysis (SAST): Medium: REDACTED
REDACTED5.8MixedStatic Analysis (SAST): Medium: REDACTED
src/agents/run_internal/turn_resolution.py6.0MixedExplicit Debt: TodoComment
src/agents/realtime/session.py6.0MixedExplicit Debt: TodoComment
src/agents/realtime/openai_realtime.py6.0MixedExplicit Debt: TodoComment
src/agents/models/openai_responses.py6.0MixedExplicit Debt: TodoComment
src/agents/model_settings.py6.0MixedExplicit Debt: TodoComment
docs/scripts/translate_docs.py6.7MixedExplicit Debt: FixmeComment
src/agents/run.py7.0Near-cleanCyclomatic Complexity: AgentRunner._run_impl (cyclomatic 239)
src/agents/run_internal/run_loop.py7.0Near-cleanCyclomatic Complexity: run_loop.start_streaming (cyclomatic 201)
src/agents/run_state.py7.0Near-cleanCyclomatic Complexity: run_state._build_run_state_from_json (cyclomatic 115)
.agents/skills/implementation-final-review/scripts/review_protocol.py7.0Near-cleanCyclomatic Complexity: review_protocol.validate_packet (cyclomatic 109)
src/agents/run_context.py7.0Near-cleanCyclomatic Complexity: RunContextWrapper.get_approval_status (cyclomatic 60)
src/agents/run_internal/oai_conversation.py7.0Near-cleanCyclomatic Complexity: OpenAIServerConversationTracker.hydrate_from_state (cyclomatic 57)
src/agents/run_internal/session_persistence.py7.0Near-cleanCyclomatic Complexity: session_persistence.resume_pending_session_write (cyclomatic 41)
src/agents/run_internal/items.py7.0Near-cleanCyclomatic Complexity: items.drop_orphan_function_calls (cyclomatic 36)
src/agents/extensions/models/any_llm_model.py7.0Near-cleanCyclomatic Complexity: AnyLLMModel._fetch_chat_response (cyclomatic 30)
src/agents/extensions/models/litellm_model.py7.0Near-cleanCyclomatic Complexity: LitellmModel._fix_tool_message_ordering (cyclomatic 30)
src/agents/mcp/server.py7.0Near-cleanCyclomatic Complexity: MCPServerStreamableHttp.call_tool (cyclomatic 30)

How the grades work

Every finding carries one of four grades. Three say how serious it is. The fourth says this survey could not settle it — and it is a grade, not a gap.

Critical — 4

A definite problem that already costs you something and drags the score down: a missing authorisation check, a dependency with a known exploit, a build that does not reproduce. Failure here tends to cause failures elsewhere.

Serious — 752

Likely wrong, but not failing yet. It degrades the codebase over a longer horizon and can cause failures elsewhere — not urgent this week, not something to carry for two years either.

Minor — 59

Recorded, with no effect on how the codebase functions. Present so the survey is complete, not because it needs doing.

Could not be resolved — 17

Something this survey could not settle from the outside, and which could be critical or serious. Either a control was required and no positive evidence of it exists in the repository — a backup job that nothing shows was ever restored from proves nothing about restores — or our own analysis could not run over that part of the tree. This is not a clean result. These are excluded from the score rather than awarded a pass, so the number on the cover neither rewards nor penalises them: if you act on this survey without resolving them, you carry that risk yourself. Each one is named under Limitations.

Methodology & how to trust this report

This survey is a deep, periodic assessment — run each sprint, monthly, or quarterly, taking the time to go wider and deeper than a quick check and surfacing in one coherent report what you'd otherwise piece together from a dozen separate tools. It scores deterministically: the same commit yields the same score, every run. All 57 evaluated dimensions are computed by tools and static analysis; no language model sets or judges any of them. Overall confidence is 0.9, the weighted average across measured dimensions.

Every figure here is one of two kinds, and we label which: ✓ Measured — a deterministic fact (LoC, complexity, coverage); ~ Modeled — an estimate from a stated model (cost, effort, value-at-risk), always a range with its assumptions, never a precise fact. We never present a modelled estimate as if it were measured. Perfect or absent scores carry their provenance too (ADR-0011): ✓ Tool-verified means the property itself was measured across the surface; ○ Nothing flagged means the probes came back clean — a claim bounded by what a repository can show; ⊘ Not evidenced means a working control (a tested restore, an automated rollback) showed no positive evidence — absence of evidence is not evidence of a control, so it's excluded from the score rather than awarded a spurious 10.

What we checked — 57 dimensions across the health lenses
D1D2D3D4D6D9D11D13D14D15D16D17D19D26D27D28D29D30D31D34D35D36D37D43D44AX10AX3AX4DM6M1M2M3P1P10P2P3P4P6PF3X1X12X13X14X15X17X19X21X22X23X24X25X26X27X28X3X30X4

Each chip is a dimension scored from real signals across architecture, testing, dependencies, security & compliance, documentation, git-history and code quality — in one coherent pass. A surface report typically covers a handful.

How to trust any code-health report — three questions
  1. Can you open the finding? Real findings cite a repo-relative file and line you can open at the cited line — never an absolute scratch path. Here, 809 of 815 do; the remainder are repo-wide signals — a dimension-level measurement, not a single line. (Every path in this report is repo-relative by construction: paths are normalized at the producer and the report is rejected if any rooted path leaks through.)
  2. Is there a tool behind the number? Every score below names the method that produced it: Roslyn, git or a scanner, not a narrative.
  3. Does re-running give the same result? Run it again on the same commit and the score — and this report, byte for byte — is identical. A report whose numbers move between runs is describing the run, not the code.

This report answers yes to all three. That's the bar to hold any assessment to.

Tools & methods

The actual versions used this run (captured at analysis time) — re-run on the same commit for the identical score.

MethodBacksVersionEvaluator
Roslyn static analysisComplexity, cohesion, coupling, dead code, API surface, layering5.3.0✓ deterministic
Native secret scannerHardcoded secrets / credentials1.0.0✓ deterministic
Canine Code Analyzer duplication detector (in-process)Code duplication1.0.0✓ deterministic
Coverage (coverlet / dotnet-coverage)Line & branch coverage10.0.400✓ deterministic
NuGet / dotnetOutdated, vulnerable & deprecated dependencies10.0.400✓ deterministic
git / LibGit2SharpChurn hotspots, knowledge concentration, history2.43.0 · 0.31.0✓ deterministic
gitleaks · semgrep · trivy · checkovSecrets in history, SAST, CVEs, IaC & container, PII / GDPR1.86.0 · 0.69.3 · 3.2.533✓ deterministic

Every finding is locatable in findings.md. Run 01a1a4c5-5603-72bd-8c5c-ea802ff419fe.

The exact command behind every deep-scan dimension — tool, version, invocation and retained raw output — is in Appendix B — Reproduction & audit trail.

Run transparency — what happened this run

What ran differently this time — a tool absent, degraded, or that fell back to an estimate. Named openly, not folded silently into the scores. A degraded run also records its exact cause in diagnostics.md.

  • D8 Code Coverage — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Coverage NOT READ here — but this repository measures it: a coverage step in CI (`coverage run`) shows that coverage is collected and tracked in your own CI. The built-in collector has no runner for this ecosystem (.py), so the analyzer could not read the number — a gap in the analyzer's language coverage, not an unmeasured repo. Not scored. To have the real number read, produce a coverage report in a standard format (`coverage run -m pytest` then `coverage xml`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures. You can widen what we reach: optional: produce a coverage report in a standard format (`coverage run -m pytest` then `coverage xml`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures — then the real number is read on the next scan.
  • D12 Dependency Hygiene — not measured this run — This is a true statement about the repository that carries nothing for its owner to act on, so it is reported here rather than as a defect in their code. This repository's 13 shipped Python distribution(s) across 1 manifest(s) WERE read; what went unanswered is the currency half, because it grades an EXACT pin against the newest release and every declaration here is a floor or a range — which installs the newest release it admits and so cannot be behind one. So pypi.org was never asked. This is a true statement about the repository, and the healthy one, NOT a gap on our side: no reader we could write would find a currency question here.
  • D19 Documentation Quality — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. Each ecosystem's manifests (what makes a folder runnable or a published package) need their own proof before D19 judges its units. Until then those folders' READMEs are judged only as documents (boilerplate, structure), never counted as complete.
  • D21 Naming Consistency — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D21's deterministic naming rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. Until then its declarations carry no naming verdict this run — this says nothing about whether its names are consistent.
  • D22 Internal API Consistency — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. D22's deterministic call-shape rules are gated on C# first (docs/plans/deterministic-engine.md, P5): each other language is switched on only after its own concept suite and A/B gate pass. This says nothing about whether that surface is consistent.
  • D24 Comment Value — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Each source language's comment syntax, and the code a comment annotates in it, needs its own proof before D24 judges it. Until then those comments are left unread, not counted as clean.
  • AX1 Captive dependencies — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads Microsoft.Extensions.DependencyInjection registrations in C# and Spring beans in Java/Kotlin only, and this repository defines its own container in src/agents/sandbox/session/dependencies.py, whose lifetimes are not modelled yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • AX6 Interface segregation — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check is computed over the public interfaces this run's compilations declare, and none was loaded, so it had nothing to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • AXR1 Runtime accessibility — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. Render strategy: boot via Dockerfile (examples/sandbox/tutorials/Dockerfile). the image ran but published no HTTP port — nothing to crawl (EXPOSE the web port to unlock runtime evidence).
  • C1 Data Protection — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These personal data controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks personal data controls.
  • GD1 Unfinished & placeholder code — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, F#, JavaScript/TypeScript, Dart, Ruby and Scala source only, and no C#, F#, JavaScript/TypeScript, Dart, Ruby or Scala was found, and this repository's Python is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • IC1 Incompleteness & stubs — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, JavaScript/TypeScript, Java, Dart, Ruby and Scala source only, and no C#, JavaScript/TypeScript, Java, Dart, Ruby or Scala was found, and this repository's Python is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • P8 Schema migrations — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. The schema may be created by a runner, a deploy script or a config file outside what this check reads, so an absence here is our blind spot rather than a missing migration strategy. The card abstains instead of scoring. You can widen what we reach: if the schema is created and evolved by a tool this check does not name, naming it lets us teach the detector to read it.
  • S1 Web-Security Posture — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. These web-security controls are read from declarative annotations, request middleware, entity/column names and guard methods in a C# source model, and none was loaded on this run, so there was nothing to gather. That is a gap in this analyzer's language reach — not a finding that the repository lacks web-security controls.
  • X16 Unfloored truncation loop — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript, Java, PHP, Dart, Ruby, Scala and Kotlin source only, and no C# was loaded and no JavaScript/TypeScript, Java, PHP, Dart, Ruby, Scala or Kotlin was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X18 Disposal-pattern correctness — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript, Java, Kotlin, Dart, Ruby, Scala and PHP source only, and no C# was loaded and no JavaScript/TypeScript, Java, Kotlin, Dart, Ruby, Scala or PHP was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X29 Per-element action decided by a fixed element — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax, and JavaScript/TypeScript (Vue and Svelte components included), Java, Rust, Dart, Ruby, Scala and Kotlin source only, and no C# was loaded and no JavaScript/TypeScript, Java, Rust, Dart, Ruby, Scala or Kotlin was found in this repository, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.
  • X3 Exception handling — measured, with a gap in what it reached — We measured this, but not all of it. What we did not reach is a gap on our side — a collector, parser or image we have not built yet — so the numbers on that dimension cover less than the repository, and the part left out is not evidence that it would have passed. 46 further occurrence(s) are not listed individually; the score already reflects all 86.
  • X5 Nullable reference types — not measured this run — We could not measure this here. That is a gap on our side — a collector, parser or image we have not built yet — and it is neither a defect in this repository nor evidence that the check would have passed. This check reads C# syntax and MSBuild project configuration, TypeScript source and its tsconfig files, Java source and its package and module declarations, PHP source and its PHPStan and Psalm configuration, Dart source and its pubspec language version, Ruby source and its Sorbet and Steep configuration, Scala source and its build's explicit-nulls, WartRemover and Scalafix settings, and Kotlin source only, and no C# was loaded, no TypeScript was found, and this repository's Python is not read yet, so it had nothing of this repository's product to read. That is a gap in this analyzer's language reach — not a finding that the repository is free of what this check looks for.

Repo exclusion declarations (.gitattributes linguist-generated/vendored, .editorconfig generated_code): none declared — every source file was scored.

Limitations & what we did not check

We assess the repository exactly as committed, and only the repository. By design we do not reach outside the source tree: the live cloud account, the running CI/CD pipeline, the host's branch-protection and approval rules, the production configuration, or a restore actually exercised against a backup are all out of scope. That boundary is a feature, not a gap — a repo-relative, deterministic scan re-runs identically on any commit and every finding opens at a real file and line, where a live audit can neither be reproduced nor traced. The visible consequence is that controls which leave no in-repo evidence are reported as "not evidenced" and excluded from the score rather than awarded a number a static scan cannot justify.

Per-dimension blind spots

For each dimension that was measured, what a static, repo-only scan structurally cannot see — the honest edge of the measurement, not a failure of it.

  • D1 Cyclomatic Complexity: Cyclomatic complexity counts branches statically — it cannot tell an essential decision tree from accidental tangle, nor see complexity that lives in data or configuration (large switch-case token tables, DSL lexers/parsers, data-as-code rule tables) rather than control flow: a tokenizer's many single-character cases read as high complexity though each branch is trivial.
  • D2 Cognitive Complexity: Cognitive-complexity heuristics approximate how hard code is to follow; genuine domain difficulty and well-named intent that eases reading are not captured.
  • D3 God Classes: "God class" is sized by members and responsibilities visible in the type — a deliberately broad facade over a coherent subsystem can read the same as an accidental grab-bag. For front-end JS the file-length check is cohesion-aware (a single-responsibility module — one class/IIFE — earns a 3× threshold), but cohesion is approximated from top-level declarations, not true dependency structure.
  • D4 Code Duplication: Duplication is token-similarity — an in-process token-stream comparison over sliding windows, with type-aware normalization — so it finds copy-paste, not semantic duplication expressed differently. Committed machine-written code (scaffolded migrations, designer/codegen output, protobuf/OpenAPI stubs, model snapshots) is EXCLUDED — its repetition is the tool's, not the team's — so the score reflects hand-written duplication only.
  • D6 Cohesion (LCOM4): LCOM4 cohesion is syntactic — it infers connectivity from which methods touch which fields/methods by name, not from real runtime behaviour or intent.
  • D9 Test Distribution: The test-pyramid shape is inferred from project/folder naming and references, with a single test host bucketed per-file by its path tier and content signals — a suite that names tiers unconventionally and gives no per-file signal can still be mis-bucketed.
  • D11 Test Reliability: Flakiness is inferred from history/markers — we run the suite once (for coverage), not the repeated runs under varied conditions that reveal nondeterminism, so a flaky test never recorded as failing is invisible here.
  • D13 Secret Scanning: Secret detection is signature- and entropy-based on the current tree — a secret that does not match a known pattern, or one already rotated, will not be flagged (a clean scan is "nothing matched", not "no secrets exist").
  • D14 License Compliance: License compatibility is checked against declared package metadata and a policy — mislabelled or missing license metadata, and obligations that depend on how you distribute, are not resolved here.
  • D15 Churn × Complexity Hotspots: Churn hotspots come from git history — a freshly imported or squashed repository has no churn signal, and recent rewrites can mask a historically risky file.
  • D16 Bus Factor: Bus-factor is a time-decayed model of commit attribution (who has recently, repeatedly worked a file), not comprehension — pairing, review and reading-without-committing spread knowledge it can't see; bot commits and shared accounts still distort it.
  • D17 Explicit Debt: Acknowledged-debt signals (TODO/FIXME, suppressions, dead code) are textual — undocumented debt that nobody marked, and debt that lives in design rather than annotations, is invisible. Committed machine-written code (scaffolded migrations, designer/codegen output, generated stubs) is excluded — it is never the team's dead code to delete.
  • D19 Documentation Quality: Documentation quality publishes two things only: a runnable or packaged unit with no example, and a multi-project root README that maps none of its parts. It does not judge clarity, and its other checks (overview, licence, boilerplate, structure, empty sections, XML-doc coverage) are withheld after adjudication: their candidates are counted in the card's gaps, not shown as rows. A false statement in a document is M4's; units are .NET projects only.
  • D26 Project Cohesion: Project focus is sized from members/namespaces per project — a project that is broad by deliberate design reads the same as one that has sprawled.
  • D27 Navigability: Indirection/navigability is structural — it measures hops to follow a call, not whether that indirection buys real flexibility or just ceremony.
  • D28 Secrets (history): Secret-history scanning sweeps the git log for known patterns — a secret that predates the available history, or never matched a signature, is not found (clean means "nothing matched in the history we can see").
  • D29 Static Analysis (SAST): SAST findings are pattern-based (semgrep) — it finds classes of bug it has rules for; logic flaws, auth/authorization gaps and issues needing runtime context are out of reach (and clean means "no rule matched").
  • D30 Dependency Vulnerabilities: CVE matching depends on accurate package/version metadata and on the advisory databases — a vulnerability with no published advisory, or in code not declared as a dependency, is not seen. Coverage needs a RESOLVED graph: an unpinned requirements.txt, or a pom without a resolved build, yields partial coverage rather than a clean verdict. An ecosystem the analyzer cannot scan is reported as unmeasured, never as clean.
  • D31 IaC & Container Security: IaC scanning checks Dockerfiles/Terraform/Kubernetes against best-practice rules — it cannot see the live cloud account, runtime configuration, or drift between the committed config and what is actually deployed.
  • D34 Knowledge Freshness: Freshness is decayed commit RECENCY, not comprehension — code read often but rarely committed reads as orphaned, and stable code that genuinely needs no changes is penalised the same as forgotten code; bot/squash commits distort it like the bus factor.
  • D35 Change Coupling: Change coupling is co-change in COMMITS — files split across separate commits, or coupled only through a shared config/build step, read as uncoupled, and a sweeping commit (rename/format) is excluded so it doesn't couple everything. It shows that files change together, not WHY: a high coupling can be a healthy cohesive pair as readily as a hidden leak.
  • D43 Malicious Dependencies: Only packages some vulnerability database has already NAMED as malicious are seen — a compromise published in the last hours, or never reported at all, is invisible here, and this dimension reading 10 is not evidence that a dependency is trustworthy. There is no typosquat or dependency-confusion analysis: a package nobody has reported is simply absent from the feeds. Coverage is the dependency scan's: an ecosystem that could not be scanned is disclosed as unmeasured, never as clean.
  • D44 Platform End-of-Life: The support table is FROZEN, so it goes out of date by losing RECALL: a release that ended support after the table was written is missed until the table is refreshed, and this dimension reading 10 is not evidence that a platform is current. Only platforms the repository DECLARES in a place this pass reads are seen — a runtime named only in a Dockerfile (D31's subject), in a CI workflow (D29's), or in a file this pass does not parse (go.mod, a Gemfile ruby directive) is invisible here, which is why a repository declaring none of them abstains rather than scoring. Only frameworks with a PUBLISHED support policy are tracked: React, Flask and Express publish none, so their age cannot be judged and their absence from a report is not a statement that they are supported.
  • AX10 Code composition: Role is inferred from namespace/folder convention, not semantics — a domain concept living in a folder named "Services" reads as application, and the split is lines-of-code, not business value. The business-logic-share score is a SOFT, FLOORED signal: it contributes to the Architecture lens but is floored at the Critical gate, so an infrastructure-heavy design (a gateway, an ETL, a driver) is legitimately low without being nuked to zero.
  • DM6 Domain ↔ infrastructure boundary: Infrastructure reached through a hand-rolled wrapper, a domain-named facade, reflection, or a string-keyed service locator resolves to a non-infra type and isn't seen; the body scan is symbol resolution over syntax, not full dataflow. A clean result means "no resolved infra reference in a domain body", not a proof of purity.
  • P4 Deployment & Rollback: Approval/branch-protection rules live in repository settings the scan cannot see — only their in-repo evidence (config files, workflows) is checked, so a control enforced purely in the host's settings reads as "not evidenced".
  • P6 Release Hygiene: Rollback/observability controls are inferred from repo artefacts (pipelines, dashboards-as-code) — controls configured in external tooling, with no in-repo trace, cannot be credited.

Dimensions

D1 · Cyclomatic Complexity3.0 / 10Weak✓ Tool-verified

What it measures: How tangled the control flow is — methods with many branches are hard to test and change.

Method: Cyclomatic complexity per method (1 + decision points), computed exhaustively across production source; test projects separated by convention. Deterministic.

Maturity: Documented → Verified → Prevented · effective 3.0 / 10 · rule-coverage 100% · ceiling Prevented

131 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was AgentRunner._run_impl at 239. A further 2 method(s) were over the threshold but excluded as flat dispatchers (a long switch/match over independent cases: many branches, almost no nesting), the largest being Converter.convert_tool_choice at 20 — they are counted neither in the figure above nor in this dimension's score. 1 file carries no cyclomatic complexity row at all for this reason — every one of its over-threshold methods was excluded, so the exclusion is disclosed nowhere in the file itself: src/agents/run_internal/streaming.py (streaming.stream_step_items_to_queue at 16). They are named here because the per-file figures other dimensions report are taken BEFORE this exclusion, so such a file can show a high maximum complexity elsewhere in this report and nothing here, with nothing to reconcile the two.

AgentRunner._run_impl (cyclomatic 239)src/agents/run.py:629
run_loop.start_streaming (cyclomatic 201)src/agents/run_internal/run_loop.py:987
turn_resolution.resolve_interrupted_turn (cyclomatic 170)src/agents/run_internal/turn_resolution.py:1387
ChatCmplStreamHandler.handle_stream (cyclomatic 129)src/agents/models/chatcmpl_stream_handler.py:603
run_state._build_run_state_from_json (cyclomatic 115)src/agents/run_state.py:4174

+ 126 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 8 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with AgentRunner._run_impl (cyclomatic 239), run_loop.start_streaming (cyclomatic 201), turn_resolution.resolve_interrupted_turn (cyclomatic 170). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 8 together lifts Cyclomatic Complexity from 3.0 to about 5.5/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
  2. Enforce Cyclomatic Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.

D2 · Cognitive Complexity2.0 / 10Critical✓ Tool-verified

What it measures: How hard the code is for a person to follow, beyond raw branching.

Method: Cognitive complexity per method (Sonar-style nesting-penalized score), computed exhaustively over production code, excluding test projects. Deterministic.

Maturity: Documented → Verified → Prevented · effective 2.0 / 10 · rule-coverage 100% · ceiling Prevented

232 method(s) exceeded the cognitive complexity threshold of 15; the worst was AgentRunner._run_impl at 609.

_asyncio_tasks.gather_with_cancel (cognitive 32) · ×2src/agents/util/_asyncio_tasks.py:97
AgentRunner._run_impl (cognitive 609)src/agents/run.py:629
run_loop.start_streaming (cognitive 474)src/agents/run_internal/run_loop.py:987
ChatCmplStreamHandler.handle_stream (cognitive 319)src/agents/models/chatcmpl_stream_handler.py:603
turn_resolution.resolve_interrupted_turn (cognitive 235)src/agents/run_internal/turn_resolution.py:1387

+ 226 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Bring the 31 bodies over 60 down to 60 or less in Cognitive Complexity — start with AgentRunner._run_impl (cognitive 609), run_loop.start_streaming (cognitive 474), ChatCmplStreamHandler.handle_stream (cognitive 319). — This score is capped by its worst body, so a finding fixed alone moves it by almost nothing — the next one down takes its place. Refactoring these 31 together lifts Cognitive Complexity from 2.0 to about 3.6/10, projected with the scoring formula itself and assuming each lands exactly at 60; a cleaner split scores higher.
  2. Enforce Cognitive Complexity in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.

D3 · God Classes8.8 / 10Strong✓ Tool-verified

What it measures: Over-large classes that try to do too much ("god classes").

Method: God-class detection by line and method-count thresholds per logical type (partial classes unified), filtered for generated code and registration/contract false positives. Deterministic.

Maturity: Documented → Verified → Prevented · effective 8.8 / 10 · rule-coverage 100% · ceiling Prevented

41 god class(es) detected.

FileTooLong: agents/run_state.py · ×37src/agents/run_state.py
TooManyMethods: OpenAIRealtimeWebSocketModel · ×4src/agents/realtime/openai_realtime.py:555

What to do

  1. Resolve the 37 FileTooLong finding(s) in God Classes — start with model.py (2), items.py (2), run_state.py. — One of this dimension's main actionable groups (37 warning-level).
  2. Resolve the 4 TooManyMethods finding(s) in God Classes — start with openai_realtime.py, session.py, any_llm_model.py. — One of this dimension's main actionable groups (4 warning-level).
  3. Enforce God Classes in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.

D4 · Code Duplication9.3 / 10Stronggated by 218 serious findings✓ Tool-verified

What it measures: Copy-pasted code that should be shared instead.

Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), density-scored per KLoC of production code. Deterministic.

Maturity: Documented → Verified → Prevented · effective 9.3 / 10 · rule-coverage 100% · ceiling Verified

205 duplicated block group(s) detected. A further 13 rows report members as variants of one another; they aggregate block groups already counted above and are not themselves counted. 113 of the 218 are in trees this repository does not ship — vendored, example/demo, project-template, fixture and benchmark code — and are ranked below the shipped groups rather than excluded from them: the duplication there is real and is still counted in this dimension's score. The dimensions that publish a production-file census leave those trees out of theirs, so this count is deliberately drawn over the wider population.

Duplicated block (9 lines × 2) · ×11.agents/skills/implementation-final-review/scripts/review_protocol.py:905
Duplicated block (16 lines × 2) · ×9src/agents/models/openai_chatcompletions.py:229
Duplicated block (11 lines × 2) · ×9src/agents/handoffs/history.py:297
Duplicated block (20 lines × 2) · ×8src/agents/realtime/openai_realtime.py:1758
Duplicated block (17 lines × 2) · ×8src/agents/extensions/models/any_llm_model.py:396

+ 99 more group(s) — more in Appendix A; the complete list is findings.md.

What to do

  1. Resolve the 11 Duplicated block (9 lines × 2) finding(s) in Code Duplication — start with review_protocol.py, async_sqlite_session.py, openai_responses_compaction_session.py. — One of this dimension's main actionable groups (11 warning-level).
  2. Resolve the 9 Duplicated block (16 lines × 2) finding(s) in Code Duplication — start with run_loop.py (2), openai_chatcompletions.py, openai_provider.py. — One of this dimension's main actionable groups (9 warning-level).
  3. Resolve the 9 Duplicated block (11 lines × 2) finding(s) in Code Duplication — start with history.py, items.py, REDACTED. — One of this dimension's main actionable groups (9 warning-level).
  4. Enforce Code Duplication in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.

D6 · Cohesion (LCOM4)9.9 / 10Stronggated by 1 serious finding✓ Tool-verified

What it measures: Whether a class's methods are focused on a single responsibility.

Method: LCOM4 cohesion per production class with at least two methods: connected components of methods sharing state or calls, computed syntactically. Deterministic, not a proxy.

Coverage: Exhaustive · type-level: LCOM4 cohesion computed over every production class — the population is all types, not a name convention.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Verified

1 of 150 classes have LCOM4 above 3.

Low cohesion: BaseSandboxSession (LCOM4 4)src/agents/sandbox/session/base_sandbox_session.py:200

What to do

  1. Resolve the 1 Low cohesion finding(s) in Cohesion (LCOM4) — start with base_sandbox_session.py. — One of this dimension's main actionable groups (1 warning-level).
  2. Enforce Cohesion (LCOM4) in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Verified — provenance only; does not change the score.

Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.

D9 · Test Distribution10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the test suite has a healthy mix of unit / integration / end-to-end tests.

Method: Test projects classified (Unit/Integration/BDD/E2E) from compiled metadata; test methods counted exhaustively across projects with placement-agnostic disk fallback. Deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

8473 test methods: 8441 unit, 32 integration, 0 BDD, 0 e2e. The Python suite contributes 8473 test function(s) across 425 file(s) declaring at least one — every `def test…` in a file pytest or unittest would collect, which is those frameworks' own definition of a case; a parametrize table counts once, so this is a floor. Its tier split is read from file names and paths only.

✓ On the Gold path — maintain.

Detailed fixes: d9_recommendation.md.

D11 · Test Reliability10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the tests pass reliably, with no flakiness.

Method: Suite re-run N times within tiered wall-clock budgets (unit to e2e); tests failing non-deterministically across runs flagged; guarded tests retried when #if guards detected.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

0 flaky across 1 measured tier(s). Python (repository root, 431 test files): measured (0 flaky).

✓ On the Gold path — maintain.

Detailed fixes: d11_recommendation.md.

D13 · Secret Scanning10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether any secrets (keys, tokens, passwords) have leaked into the code.

Method: In-process native secret scanner (entropy plus signature patterns) across all tracked files; no external tool. A clean result is a measured 10, not no-data zero. Deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

Secret scan ran and found no leaked secrets.

✓ On the Gold path — maintain.

Detailed fixes: d13_recommendation.md.

D14 · License Compliance10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether the licenses of third-party packages are compatible with your policy.

Method: Third-party package licenses resolved from declared package metadata and checked against the configured policy (allow/deny/copyleft). Deterministic; clean = no incompatible license found at metadata depth.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Verified

0 of 37 shipped Python distribution(s) use a banned license. Licences were resolved from PyPI over the distributions a consumer installs — this repository's 13 declared runtime requirement(s) closed transitively over each distribution's published `requires_dist` (24 reached that way). Requirements it states ONLY under an extra, a PEP 735 dependency group, a Poetry dev group or a dev-named requirements file are excluded: pip does not install any of them for a consumer. ★ This repository commits no dependency lockfile that this pass reads, so each licence is the one PyPI publishes for the distribution's CURRENT release rather than for a pinned version. This repository publishes itself under MIT, which is its own choice and is not judged here.

✓ On the Gold path — maintain.

Detailed fixes: d14_recommendation.md.

D15 · Churn × Complexity Hotspots8.8 / 10Strong✓ Tool-verified

What it measures: Files that change often and are also complex — the riskiest hotspots.

Method: Per production file churn times cyclomatic complexity over a rolling window, computed from git and Roslyn/JS/Razor analysis. Exhaustive, deterministic per commit date.

Maturity: Documented → Verified → Prevented · effective 8.8 / 10 · rule-coverage 100% · ceiling Documented

Top hotspots: src/agents/run.py (25×239=5975); src/agents/run_internal/run_loop.py (28×201=5628); src/agents/run_state.py (39×115=4485) Repeated repair below the complexity floor: src/agents/run_internal/agent_runner_helpers.py (8 of 10 changes were fixes); src/agents/sandbox/session/base_sandbox_session.py (7 of 8 changes were fixes); src/agents/memory/sqlite_session.py (7 of 7 changes were fixes)

Hotspot: src/agents/run.py · ×46src/agents/run.py:629
Repeated repair: src/agents/run_internal/agent_runner_helpers.py · ×20src/agents/run_internal/agent_runner_helpers.py:132

What to do

  1. Resolve the 46 Hotspot finding(s) in Churn × Complexity Hotspots — start with sandbox.py (3), result.py (2), run.py. — One of this dimension's main actionable groups (46 warning-level).
  2. Resolve the 20 Repeated repair finding(s) in Churn × Complexity Hotspots — start with agent_runner_helpers.py, base_sandbox_session.py, sqlite_session.py. — One of this dimension's main actionable groups (20 warning-level).

Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.

D16 · Bus Factor9.0 / 10Strong✓ Tool-verified

What it measures: Whether knowledge is concentrated in too few people (the "bus factor").

Method: Living knowledge per author via time-decayed commit attribution (6-month half-life, focus weighting) across largest source files. Deterministic, avoids blame's mechanical-refactor false positives.

Maturity: Documented → Verified → Prevented · effective 9.0 / 10 · rule-coverage 100% · ceiling Documented

15 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is src/agents/extensions/experimental/hosted_multi_agent/model.py. Counted over 145 of the 208 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

Off-boarding risk: anonymized user #1

What to do

  1. Resolve the 1 Off-boarding risk finding(s) in Bus Factor. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.

D17 · Explicit Debt10.0 / 10Stronggated by 12 serious findings✓ Tool-verified

What it measures: Acknowledged debt left in the code — TODOs, dead code, suppressed warnings.

Method: Roslyn syntactic debt markers (suppressions/TODO/FIXME/HACK/empty-catch/commented-code/Obsolete) plus SymbolFinder dead-code analysis; weighted-debt-per-KLoC density deducted 2.0x per unit. Deterministic, exhaustive.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Prevented

12 deducted task-comment markers across 146511 LoC (0.0/KLoC) → score 10.0. Task comments only: this repository's language is read without a compiler, so D17's suppression, dead-code and commented-out-code arms did not run and this score counts fewer marker kinds than a .NET repository's would.

TodoComment · ×11src/agents/model_settings.py:160
FixmeCommentdocs/scripts/translate_docs.py:684

What to do

  1. Resolve the 11 TodoComment finding(s) in Explicit Debt — start with openai_realtime.py (2), session.py (2), model_settings.py. — One of this dimension's main actionable groups (11 warning-level).
  2. Resolve the 1 FixmeComment finding(s) in Explicit Debt — start with translate_docs.py. — One of this dimension's main actionable groups (1 warning-level).
  3. Enforce Explicit Debt in CI to reach Verified (currently Documented). — Hardens enforcement from Documented toward Prevented — provenance only; does not change the score.

Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.

D19 · Documentation Quality10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether the project's documentation is clear, complete, and useful.

Method: Every README, docs/ document and root guide parsed by its markup and measured in Unicode letters. Published: a runnable or packaged .NET project whose README (or a document it links, or a root guide) shows no example, and a root README naming none of three or more projects. Overview, licence, boilerplate, wall-of-text, empty-section and XML-doc rows are measured and withheld (counted in gaps) after adjudication. Deterministic, exhaustive, advisory.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

1 of 1 documentation facets pass in full. 404 document(s) read across 1 unit(s).

✓ On the Gold path — maintain.

Detailed fixes: d19_recommendation.md.

D26 · Project Cohesion0.0 / 10Critical✓ Tool-verified

What it measures: Whether each project is a focused, coherent unit rather than an oversized grab-bag.

Method: Project size overshoot penalties (LoC / public-type count / namespace count, 2-of-3 flag) weighted by log magnitude. Exhaustive across projects, deterministic.

Maturity: Documented → Verified → Prevented · effective 0.0 / 10 · rule-coverage 100% · ceiling Documented

1 of 2 build units (Python) flagged as possibly oversized/incoherent.

Projects may be oversized for their cohesion

What to do

  1. Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d26_recommendation.md · top locations in Appendix A, every location in findings.md.

D27 · Navigability9.9 / 10Exemplary✓ Tool-verified

What it measures: How far you must trace to follow a call — low indirection and co-located slices read easier.

Method: Call indirection (interface hops, cross-namespace calls, slice-locality scaled) over a sampled set of method invocations, size-aware baseline. Sampled; confidence discounted by symbol-resolution gaps. C# also names each pass-through layer (a class whose every public method only forwards its own parameters to one collaborator) as a located finding; the score is not affected.

Coverage: Slice locality from the first namespace segments, SAMPLED (≤400 methods) — not exhaustive.

Maturity: Documented → Verified → Prevented · effective 9.9 / 10 · rule-coverage 100% · ceiling Documented

98 % of calls cross a namespace and 0 % go through an interface, but 98 % of collaborators are co-located — so a call's collaborators sit together and tracing stays easy. Baseline: small — navigation cost is tolerated.

✓ On the Gold path — maintain.

Detailed fixes: d27_recommendation.md.

D28 · Secrets (history)10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.

Method: Secret scan via TWO gitleaks detect passes in an isolated checkout — the full git history, then a second --no-git pass over the working tree as it stands — merged and de-duplicated by (rule, file, line); each match flagged High. Both invocations are recorded in the audit trail. Exhaustive; when the tool is absent, or when its output cannot be parsed into the expected shape, the dimension is WITHHELD as an explicit measurement gap on our side — unscored and excluded from the lens, never a hedged middling score.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

gitleaks scanned the full history AND the current working tree and found no secrets.

✓ On the Gold path — maintain.

Detailed fixes: d28_recommendation.md.

D29 · Static Analysis (SAST)6.8 / 10Adequate✓ Tool-verified

What it measures: Real static-analysis (SAST) findings — likely security bugs in the code, any language.

Method: Polyglot static analysis via semgrep across the repo using the pinned, image-baked p/security-audit + p/owasp-top-ten rulesets (no scan-time registry fetch); severity rules (ERROR/WARNING/INFO) map to a full-band severity-weighted score. Exhaustive, deterministic; degrades on parse failure.

Coverage: semgrep pattern rules over all files — exhaustive for the rule set, blind to classes of bug without a rule (clean = no rule matched).

Maturity: Documented → Verified → Prevented · effective 6.8 / 10 · rule-coverage 100% · ceiling Documented

11 finding(s): 0 critical, 0 high, 6 medium, 5 low. semgrep hit a parse error in 1 file(s) — `examples/sandbox/tutorials/misc.py` — so no absence of findings in them is evidence of anything, and nothing in them was analysed. Fix the syntax error (or exclude the file deliberately) and re-scan to cover them. Separately, one or more rules could not re-parse an embedded snippet in 1 file(s) (e.g. a workflow `run:` block read as shell). Those files WERE scanned and their other rows are unaffected; only those rules' view of those snippets is missing.

REDACTED
REDACTED
REDACTED
REDACTED
REDACTED

What to do

  1. Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED, REDACTED. — One of this dimension's main actionable groups (2 warning-level).
  2. Resolve the 2 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED (2). — One of this dimension's main actionable groups (2 warning-level).
  3. Resolve the 1 REDACTED finding(s) in Static Analysis (SAST) — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).

Detailed fixes: d29_recommendation.md · top locations in Appendix A, every location in findings.md.

D30 · Dependency Vulnerabilities7.5 / 10Adequategated by 3 critical findings✓ Tool-verified

What it measures: Whether any dependency has a known published vulnerability (CVE), direct or transitive, in ANY ecosystem the repository declares — Dart pub, Elixir and Erlang via Hex, Go modules, Java and Kotlin via Maven/Gradle, JavaScript/npm, .NET/NuGet, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift.

Method: Dependency-CVE scan across every ecosystem the repository declares, scored ONCE. Three sources are unioned and deduplicated by advisory identity (rule id + alias closure, CVE<->GHSA) scoped to package+version, keeping the worst severity: `osv-scanner --recursive` over osv.dev for Dart pub, Elixir/Hex (and Erlang, whose `rebar.lock` syft first converts to a CycloneDX SBOM the scanner reads, with rows attributed back to the lock), Go, Java and Kotlin via Maven/Gradle (and Scala, whose sbt build's pinned direct declarations are written into a CycloneDX SBOM the scanner reads, with rows attributed back to the build file), npm, PHP/Composer, Python/PyPI, RubyGems, Rust/Cargo and Swift; `trivy fs --scanners vuln` for npm lockfiles; and `dotnet list package --vulnerable --include-transitive` for NuGet (with per-advisory collapse of the project x target-framework fan-out), plus a DECLARED-dependency arm that resolves a published gem's gemspec against rubygems.org where no Gemfile.lock is committed. `SeverityScore(c,h,m,l, normalizer 8.0)`. NotApplicable only when NO ecosystem is readable; if any applicable ecosystem could not be scanned the findings are REPORTED and the score is withheld. Supersedes the npm and OSV arms, retired 2026-09-05. Advisory since rubric-2026.11.2 (CAI decision 0006): every row is a match against a vulnerability database that changes daily, so the reading is shown and never moves a scored dimension, lens or the headline.

Maturity: Documented → Verified → Prevented · effective 7.5 / 10 · rule-coverage 100% · ceiling Documented

3 finding(s): 1 critical, 2 high, 0 medium, 0 low.

REDACTED
REDACTED

What to do

  1. Resolve the 2 High CVE finding(s) in Dependency Vulnerabilities — start with REDACTED (2). — One of this dimension's main actionable groups (2 issue-level).
  2. Resolve the 1 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).

Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.

D31 · IaC & Container Security10.0 / 10Exemplary○ Nothing flagged

What it measures: Whether Dockerfiles / Terraform / Kubernetes config follow security best practices.

Method: IaC/container misconfiguration scan via trivy config (Dockerfile/Terraform/K8s/Helm/CloudFormation); severity rules to 0-10 moderate normalizer. NotApplicable without manifests. Exhaustive, deterministic.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

trivy and checkov found no infrastructure-as-code or container misconfigurations.

✓ On the Gold path — maintain.

Detailed fixes: d31_recommendation.md.

D34 · Knowledge Freshness9.7 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still has living knowledge of each file, or it has been orphaned — last understood long ago by someone now gone quiet. The sibling of the bus factor: D16 asks who owns it, D34 asks whether anyone still knows it.

Method: File orphaning as total living-knowledge decay below one focused-commit's worth within a year, computed per-file from the D16 decay model. Exhaustive, deterministic over fixed history.

Maturity: Documented → Verified → Prevented · effective 9.7 / 10 · rule-coverage 100% · ceiling Documented

4 of 145 significant source file(s) are orphaned — their living knowledge has decayed to nothing, so no one currently understands them. The largest is src/agents/realtime/events.py. Counted over 145 of the 208 production source files in this repository: the rest are under the ~2,400-byte size floor this dimension measures over.

Orphaned file · ×4src/agents/realtime/events.py:1
Orphaned files with no living knowledge

✓ On the Gold path — maintain.

Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.

D35 · Change Coupling10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether files that change together actually belong together — pairs that repeatedly co-change in git history despite having no explicit code dependency, surfacing the hidden/logical coupling (and boundaries in the wrong place) a static scan can't see.

Method: Pairwise co-occurrence over the per-commit file sets in git history (production source only — tests and generated dropped): Degree-of-Coupling = shared ÷ min individual revisions, reported above noise floors (each file ≥10 revisions, ≥5 shared commits, ≥50% strength); sweeping commits excluded. Deterministic over fixed history.

Coverage: Population: PRODUCTION source files only — test and generated files are dropped before pairing, so a class co-changing with its own test (trivially ~100%) can't drown the real production↔production coupling. Pairs ranked by Degree-of-Coupling. A non-source file is never a coupling PARTICIPANT either: documentation, schemas, config and data files are dropped with the rest, so a code↔docs pair — a command and the reference page that restates it — is not reported however strongly the two co-change; nor is coupling that runs THROUGH a build step or config file.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No strong hidden change-coupling between production files.

✓ On the Gold path — maintain.

Detailed fixes: d35_recommendation.md.

D36 · Supply-chain Provenance & Signing7.5 / 10Strong✓ Tool-verified

What it measures: Whether the build pipeline provides supply-chain integrity — generated provenance/attestation, signed artifacts (cosign/sigstore), an SBOM, and pinned build actions. Presence of the configuration, not a runtime guarantee.

Method: Supply-chain provenance/signing read deterministically from CI/build config (.github/workflows, .gitlab-ci.yml, azure-pipelines, Jenkinsfile, .circleci) + the release surface: four signals — generated provenance/attestation (SLSA/in-toto/actions-attest), artifact signing (cosign/sigstore/gitsign), an SBOM (syft/sbom-action/*.spdx.json/*.cdx.json), and SHA-pinned build actions — scored 10·present/denom. NotApplicable without a build pipeline. Detects configuration presence, not runtime enforcement.

Maturity: Documented → Verified → Prevented · effective 7.5 / 10 · rule-coverage 100% · ceiling Documented

3/4 supply-chain integrity signals present (provenance, signing, SBOM, pinned actions).

REDACTED
REDACTED

What to do

  1. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
  2. Resolve the 1 REDACTED finding(s) in Supply-chain Provenance & Signing. — One of this dimension's main actionable groups (1 recommendation-level).

Detailed fixes: d36_recommendation.md · top locations in Appendix A, every location in findings.md.

D37 · Vulnerability-disclosure Policy10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether the repository publishes a coordinated-vulnerability-disclosure policy (SECURITY.md or security.txt) with a reporting contact, so finders know how to report a vulnerability. Presence of a policy file with a contact, not whether the policy is adequate or honoured.

Method: Vulnerability-disclosure policy read deterministically from the repo: a SECURITY.md (root/.github/docs) or .well-known/security.txt / security.txt, regex-checked for a reporting contact (email / URL / mailto). Present + contact → 10; present without a contact → 4; NotApplicable when no policy file exists (it may live off-repo). Detects the policy file's presence + contact, not its adequacy.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

A vulnerability-disclosure policy (SECURITY.md) is published with a reporting contact.

✓ On the Gold path — maintain.

Detailed fixes: d37_recommendation.md.

D43 · Malicious Dependencies10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether any dependency the repository declares is published as MALICIOUS rather than merely vulnerable — a package that is an attacker's work, in any ecosystem osv-scanner reads. Reported apart from D30 because the answer is binary: there is no safe version to upgrade to, and the fix is to remove the package and rotate every credential it could have read.

Method: The same dependency scan D30 reads, partitioned on the scanner's own classification rather than rescanned: a row is MALICIOUS when its id is in the `MAL-` space (the ossf/malicious-packages feed) OR its `database_specific.cwe_ids` carries `CWE-506` ("Embedded Malicious Code"). Both channels are structural; the summary text is deliberately NOT read, because a malicious-package record whose summary says only "Critical severity vulnerability" is a real shape ([GHSA redacted]) and a text matcher misses it. Scored BINARY: any surviving row is 0, whatever its severity and however many CVEs sit beside it — a hostile dependency is not a quantity. Applicability and degradation are D30's: NotApplicable only when no ecosystem is readable, and an unscannable ecosystem degrades rather than reading clean. Advisory since rubric-2026.11.2 (CAI decision 0006): the malicious-package feed is a database that changes daily, so the reading is shown and never moves a scored dimension, lens or the headline.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

No dependency in any ecosystem this repository declares is published as malicious.

✓ On the Gold path — maintain.

Detailed fixes: d43_recommendation.md.

D44 · Platform End-of-Life10.0 / 10Exemplary✓ Tool-verified

What it measures: Whether anyone still ships security patches for the platform this repository RUNS ON — the runtime it pins and the framework majors its own constraints hold it to. Separate from D12 because the question differs: a current Django on an end-of-life Python is perfectly up to date and completely unsupported, and the fix is a migration rather than a version bump. What the repository says it merely SUPPORTS is never charged.

Method: End-of-life PLATFORM read from the repository's own declarations and graded against a FROZEN, dated table of vendor support dates — no network, no feed, no API, so this dimension answers identically inside a closed scan fence. Two subjects: a RUNTIME the project pins (a single or all-end-of-life TargetFramework, a .nvmrc or .python-version, a requires-python CAP) and a FRAMEWORK major a dependency constraint cannot move off (a caret, tilde or exact version; `vue@^2.7.16` pins Vue 2). A FLOOR is deliberately never charged — `requires-python = ">=3.8"` states what a package SUPPORTS, not what it runs on — and a multi-target project is charged only when EVERY target is out of support. Runtime 4.0/product capped 8.0, framework 1.5 capped 4.5. The table is safe to freeze because a statement about support that ended in the past cannot become false: it loses recall as it ages, never precision, and a test asserts every entry predates the freeze date. Disjoint from D31 (a container image's OS layer) and D29 (the toolchain a CI workflow installs). Abstains when the repository declares no platform this pass reads — never scores it clean.

Maturity: Documented → Verified → Prevented · effective 10.0 / 10 · rule-coverage 100% · ceiling Documented

0 end-of-life runtime(s) and 0 end-of-life framework(s), read from 1 platform declaration(s) and 13 dependency declaration(s). This dimension reads what the repository says about ITSELF — a pinned target framework, a version file, a capped requires-python, a Rust toolchain pin, a framework major a constraint cannot move off. A FLOOR is deliberately never charged: `requires-python = ">=3.8"` states what the package SUPPORTS, not what it runs on, and a well-maintained library declares exactly that while running its own CI on a current release. The end-of-life facts are FROZEN and dated, so this dimension needs no network and answers identically inside a closed scan fence; as the table ages it loses recall and never precision, because a statement about support that ended in the past cannot become false. The OS layer of a container image is D31's question and the toolchain a CI workflow installs is D29's; this row is neither.

✓ On the Gold path — maintain.

Detailed fixes: d44_recommendation.md.

Frontend & cross-cutting dimensions

R = React/JS · M = Maturity · P = Readiness.

AX10 · Code composition9.9 / 10Exemplary✓ Tool-verified

Other · Architecture — How the codebase splits by code ROLE — domain, application, infrastructure, test, generated. The significance map behind the knowledge/coupling weighting, and a DDD signal in its own right: a thin domain core under fat infrastructure is the anemic-domain smell, quantified. How each file's role is decided, because the split is only as good as that: a generated name or a build-output tree makes it Generated, a test project makes it Test, and otherwise the file's NAMESPACE and PATH words are matched against fixed vocabularies in a fixed ORDER — domain, then infrastructure, then application — so a file whose words hit two layers is counted under the earlier one. A production file matching none of them counts as application, so that share reads 'application or unclassified' rather than a measured application layer. Roles come from naming convention, never from what the code does. On this repository the split was taken from the source tree on disk rather than from a loaded .NET workspace, so a file's role is decided by its PATH segments alone — no declared namespace was available to add to the evidence — and generated output is excluded from the census entirely rather than counted as a generated share.

Method: Roslyn line-count by code ROLE: every source file classified Domain/Application/Infrastructure/Test/Generated by namespace + path convention (the shared CodeRoleClassifier), then significant lines summed per role. Deterministic; the advisory score is the business-logic (domain+application) share of production code.

Coverage: Population: ALL source files, each bucketed into ONE of five roles (Domain/Application/Infrastructure/Test/Generated) by namespace + path convention — a file whose layer isn't named in the convention falls to Application (the neutral default), and the split is line-count, not semantic depth or business value.

What to do

  • The domain core is a small share of production code, but most of the rest matched no layer vocabulary at all — so this is not yet an anemic-domain finding. The namespace/path convention could not place that code, which makes the composition above a statement about the naming, not about the design. Name the layers (or check that the repository's conventions differ from the ones this check knows) before reading a thin domain into it.
AX3 · Project dependency cycles10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether the project-reference graph is acyclic (cycles block independent build/deploy and signal eroding boundaries).

Method: Project reference cycles via elementary-DFS over real .csproj references, using the engine shared with D5/D7; cyclic versus acyclic. Exhaustive, deterministic.

AX4 · Dependency direction10.0 / 10Exemplary✓ Tool-verified

Other · Architecture — Whether dependencies point inward (Domain ← Application ← Infrastructure/Web) — the clean-architecture dependency rule, checked across the project graph.

Method: Layer violations by name-segment inference (Domain/Core to Application to Infrastructure/Web) over the project-reference graph. Exhaustive over all projects, deterministic.

DM6 · Domain ↔ infrastructure boundary5.4 / 10Adequate✓ Tool-verified

Other · Domain Modelling — Whether the domain layer stays free of infrastructure dependencies — a domain aggregate fused to a persistence ORM (Django/SQLAlchemy) on its own declaration (active-record) couples the domain to infrastructure. The clean-architecture dependency rule.

Method: Roslyn (DDD-gated): domain-layer types scanned for infrastructure usage in member SIGNATURES and inside method/accessor BODIES — resolved calls and object-creations into EF/Marten/HTTP/Mongo/Redis/message-bus types (not just a namespace allowlist). Deterministic, symbol-resolved, exhaustive over domain-layer bodies, DDD-native.

Coverage: Domain layer identified by NAMESPACE heuristic; infrastructure then resolved by symbol in member SIGNATURES and method/accessor BODIES — rename the layer and the check evaporates.

  • `OpenAIHostedMultiAgentModel` is a domain concept fused to persistence ON ITS OWN DECLARATION (Django/SQLAlchemy — `models.Model`/`db.Model`) — the domain entity IS the ORM row (active-record), and it carries domain behaviour on the persistence type. A schema/persistence change ripples straight into the domain. Keep the ORM/table mapping on a boundary data-model + a mapper, and the domain entity framework-free (map row↔domain through a repository). — src/agents/extensions/experimental/hosted_multi_agent/model.py:369

What to do

  • Keep the ORM/table mapping on a boundary data-model + mapper; leave the domain entity framework-free (map row↔domain through a repository).
M1 · Documentation (README)8.7 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repo and its projects have a README, and whether it's substantive and current.

Method: Filesystem scan: README presence, word count, and headings for depth; git history for staleness. Exhaustive across root and project dirs, deterministic.

What to do

  • Explain in the README how to run the tests. Add a section called Testing to the README in the repository's top folder, saying how to run the test suite.
  • Add an 'Architecture' / 'How it works' section to the root README — the high-level shape.
M2 · Architecture documentation5.0 / 10Adequate✓ Tool-verified

Maturity · Maturity — Whether key decisions (ADRs) and the high-level shape (C4/diagrams) are written down.

Method: Filesystem scan: ADR folder/naming conventions or content, plus Mermaid/PlantUML/C4/architecture.md discovery. Exhaustive, deterministic.

  • No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.

What to do

  • Record your significant design decisions. Write one short document per decision, giving its date, the situation, the decision and its consequences, and keep them together with your other design documents. A docs/adr folder with each file named by number and title is the easiest place to find them.
M3 · Folder & project structure10.0 / 10Exemplary✓ Tool-verified

Maturity · Maturity — Whether the repo is organised deliberately — src/test separation and consistent project naming.

Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.

P1 · CI/CD gates10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — Whether an automated pipeline builds and tests every change.

Method: Filesystem scan: CI workflow files (.github/workflows, .gitlab-ci.yml, etc.) for build and test stages. Exhaustive, deterministic.

P10 · Library API & versioning10.0 / 10Exemplary○ Nothing flagged

Readiness · Readiness — For a library: a deliberate (small) public API surface and explicit semantic versioning so consumers can depend on it safely.

Method: Roslyn scan: public API surface area and semantic-versioning markers (SemVer attributes, changelog entries) for libraries; off .NET, a library is the ecosystem's publication act (an npm package that is not private and names an entry point, a PyPI distribution with a build system, a Rust library crate, a Maven/Gradle module that publishes, a Go module with no package main, a gemspec, a Composer library, a SwiftPM library product, a pub.dev or Hex package), its surface is the share of types the language's code model records as public (Rust, Swift, Java, Kotlin, Go, Dart; not measured where the model records no type visibility or, as in TypeScript, only module-level export), and its version is read from the manifest, a semver CHANGELOG, release tooling or semver git tags. Exhaustive, deterministic.

P2 · Observability7.0 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.

Method: Filesystem/Roslyn scan: structured-logging frameworks (Serilog, NLog), OpenTelemetry, and health-check endpoint patterns. Exhaustive, deterministic.

What to do

  • Consider OpenTelemetry tracing/metrics (opentelemetry-sdk) and a health-check endpoint (a /health route) for operability.
P3 · Security & performance tooling7.0 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether SAST, secret/dependency scanning and performance benchmarking are wired in (presence, not runtime).

Method: Filesystem scan: SAST configuration, dependency-update automation, secret scanning, and a benchmark harness or benchmark step — in this repository's own ecosystem. Exhaustive, deterministic.

What to do

  • Add gitleaks/trufflehog in CI to block PRs that introduce committed secrets.
P4 · Deployment & Rollback7.0 / 10Strong✓ Tool-verified

Readiness · Readiness — Whether releases are automated and safely reversible (probes, rolling updates, approval gates) — from manifests/pipeline files, not the live environment.

Method: Filesystem scan: deployment manifests/IaC (K8s YAML, Helm, Terraform) for rolling updates, probes, approval gates, migration hooks. Exhaustive, deterministic.

P6 · Release Hygiene10.0 / 10Exemplary✓ Tool-verified

Readiness · Readiness — Whether releases are traceable — a maintained changelog and explicit version stamping.

Method: Filesystem scan: changelog file presence and version tags in csproj or git tags. Exhaustive, deterministic.

PF3 · Async & latency hygiene10.0 / 10Exemplary✓ Tool-verified

Readiness · Performance — Whether asynchronous code stays responsive — it avoids sync-over-async blocking (a .NET .Wait()/.GetAwaiter().GetResult(), a time.sleep or blocking HTTP call inside a Python coroutine, a *Sync call inside an async JavaScript function, block_on inside a Rust async fn, runBlocking inside a Kotlin suspend function, block() inside a Reactor publisher) that stalls a thread or event loop and risks deadlock, and, where the code is a reusable library on .NET, awaits with ConfigureAwait(false) so it never captures and stalls its caller's context.

Method: Production-source scan: sync-over-async blocking counted everywhere — .Wait()/.GetAwaiter().GetResult() in .NET; off .NET, read from each language's code model, a blocking call inside an async function (Python, TS/JS, Rust, Kotlin, Swift, Dart) or inside a Java method returning a Reactor Mono/Flux or a Scala method returning a Future or effect — and, for a .NET library with ≥5 awaits, the share of awaits using ConfigureAwait(false). Deterministic, syntax/text detection.

X1 · Async correctness10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether the code avoids sync-over-async (deadlock-prone blocking on tasks) and async void.

Method: Roslyn syntax scan: async methods scanned for .Wait()/.GetAwaiter().GetResult() and async-void outside event handlers. Deterministic, hard fact per invocation.

X12 · Unreachable branch10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether any branch is dead by construction — a switch arm whose label can never equal a case-normalised subject, or an `else if` whose predicate the arm above has already swallowed.

Method: Roslyn syntax + semantics: switch labels compared against the subject's own case normaliser, and if/else-if chains checked for a literal an earlier arm's containment test already swallows. Deterministic, provable per finding. Advisory.

X13 · Undrained process stream10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a child process that has BOTH standard streams redirected drains both — reading one to the end while the other is never read deadlocks once the child fills the unread pipe.

Method: Roslyn syntax + semantics: ProcessStartInfo launches with both streams redirected, checked for a drain of each stream across the enclosing type. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `spawn` imported from `child_process` whose stdout and stderr are both pipes (no options, no `stdio`, or `stdio` of `'pipe'`), bound to a local that never leaves its scope, where exactly one of the two streams is read, the other never, and the child’s `close`/`exit` (or the read stream’s end) is awaited; a shell redirect in the call’s arguments or a `kill` of the child suppresses it. The same rule reads Python’s `subprocess.Popen`, Dart’s `Process.start`, Ruby’s `Open3.popen3`, and Scala’s JDK process starts (`new ProcessBuilder(…).start()` with no `redirectErrorStream`/`redirectError`/`redirectOutput`/`inheritIO`, `Runtime.getRuntime.exec`) where one of `getInputStream`/`getErrorStream` is read and the other never while `waitFor()` is called or the read stream is read to its end. Deterministic, provable per finding. Advisory.

X14 · Bypassable address classification10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a hand-rolled public/private IP check can be walked past — a method that unwraps IPv4-mapped IPv6 but returns the opposite verdict for the same host written as IPv4-compatible, 6to4 or NAT64.

Method: Roslyn syntax + semantics: methods that unwrap IPv4-mapped IPv6 and hand-roll IPv4 range carve-outs, checked for whether the IPv6 branch also accounts for the IPv4-compatible, 6to4 and NAT64 embeddings. Deterministic, provable per finding. Advisory.

X15 · Unvalidated length from an untrusted reader10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether a length read out of the stream being parsed is bounded before it is allocated or read — an unchecked count taken from the input lets the input choose the allocation.

Method: Roslyn syntax + semantics: integer lengths read from a BinaryReader and spent on a bulk read or an array allocation, checked for any comparison or bounding call on the value anywhere in the method. Deterministic, provable per finding. Advisory.

X17 · Uncapped recursion over a caller-supplied document2.0 / 10Critical✓ Tool-verified

Other · Security — Whether a walk that recurses through a JSON/XML tree handed in by its caller bounds how deep it will go — an uncapped walk lets the document's nesting choose the stack depth, and the resulting StackOverflowException cannot be caught.

Method: Roslyn syntax + semantics: methods that take a JSON/XML document node and call themselves with a child of it, reachable from an externally-callable member of the same type that accepts a document, checked for any depth parameter, descent counter or threaded arithmetic anywhere in the walk. On a repository with no .NET source it reads TypeScript off the engine’s own token stream (test, vendored, generated and minified paths and `.d.ts` not) with the same rule: a function or method with a parameter typed as a document value — `unknown`, `any`, `object`, `Record<string, unknown|any>`, a JSON alias (`JsonValue`, `JSONObject`, …) or a DOM node global the file does not rebind — that calls itself (bare, or through `this` for a method, or hands itself to a call over the value as in `value.map(walk)`) with something it took out of that value and never through an ancestor accessor such as `closest()` or `parentElement`, that is exported or reached from an exported function (a public method of the same exported class) taking such a value, and that names no depth, level, nesting, recursion, remaining or budget anywhere and threads no `+`/`-` arithmetic through a self-call. Plain JavaScript is not read: with no annotation nothing tells a parsed document from a tree the code built itself. Deterministic, provable per finding. Advisory.

  • `arguments_unchanged` is public, takes a document from its caller (line 111) and hands it to `_same_json`, which calls itself at line 164 (`_same_json`) with a piece of `left` (and at line 167) — and nowhere in `_same_json` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_same_json` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — src/agents/_function_tool_arguments.py:164
  • `from_json` is public, takes a document from its caller (line 2433) and hands it to `_validate_run_state_json_value`, which calls itself at line 2559 (`_validate_run_state_json_value`) with a piece of `value` (and at line 2563) — and nowhere in `_validate_run_state_json_value` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_validate_run_state_json_value` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — src/agents/run_state.py:2559
  • `ensure_strict_json_schema` is public, takes a document from its caller (line 116) and hands it to `_json_values_equal`, which calls itself at line 519 (`_json_values_equal`) with a piece of `left` (and at line 526) — and nowhere in `_json_values_equal` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_json_values_equal` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — src/agents/strict_schema.py:519
  • `resolve_openai_harness_id_for_model_provider` is public, takes a document from its caller (line 65) and hands it to `_harness_id_from_model_provider`, which calls itself at line 103 (`_harness_id_from_model_provider`) with a piece of `model_provider` — and nowhere in `_harness_id_from_model_provider` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_harness_id_from_model_provider` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack. — src/agents/models/openai_agent_registration.py:103

What to do

  • Each finding names the externally-callable member that accepts the document and the self-call that descends, and states that no depth parameter or counter exists anywhere in the walk. Confirm from the two, then thread a depth argument through the walk and reject documents past a fixed maximum, or rewrite it with an explicit stack.
X19 · Unrestored process-global state10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a method that temporarily changes state belonging to the whole process — the working directory, an environment variable — puts it back on EVERY path: a restore reached only when nothing throws leaks the change to the rest of the process.

Method: Roslyn syntax + semantics: method bodies that write the process working directory or an environment variable and write it back in the same body, checked for whether that restore sits in a `finally`/`catch` or only on the straight-line path. On a repository with no .NET source the same rule reads production JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not): `process.chdir`, `process.env.NAME =`/`["NAME"] =` and `delete process.env.NAME`, and Deno’s `Deno.chdir`/`Deno.env.set`/`Deno.env.delete`, paired per function body (a nested function or arrow is its own body, and module top-level code is none), where the last write puts back a local the body captured from the same global or deletes a variable the first write set, with at least one statement between them; a write in a `catch`/`finally` of that body silences it. Deterministic, provable per finding. Advisory.

X21 · Side-effecting pattern guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `when` guard is free of side effects — a guard that increments a counter or assigns while deciding whether its arm matches applies that change during PATTERN MATCHING, on an arm that may not be selected, and skips it entirely when a short-circuit to its left answers first.

Method: Roslyn syntax: `when` guards on case labels and switch-expression arms, read for a mutation (`++`/`--`/assignment) sitting in a position the guard's own `&&`/`||`/`??`/`?:`/`?.` can skip. Deterministic, provable per finding. Advisory.

X22 · Contradicted release guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a method that TAKES a lock or semaphore and gives it back from a flag-guarded `finally` returns the value that flag implies — reporting success while the guard hands the primitive back admits a second caller the exclusion was there to keep out, and reporting failure while the guard keeps it leaves nothing to ever give it back. Also whether a `finally` that gives the primitive back unconditionally can run in a state where the method does not hold it: after a timed wait whose result was discarded, after an acquire inside the `try` that can fail, after the body already released it, or never, because a `return` left between the acquire and the `try`.

Method: Roslyn syntax: `try` statements whose `finally` releases a synchronisation primitive under a bare local-bool guard, where the method also TOOK that same primitive before the `try`, checked for a `return` of a bool literal whose value disagrees with the flag state the method's own straight-line assignments put it in. Deterministic, provable per finding. Advisory.

X23 · Unguarded diagnostic materialisation6.2 / 10Adequate✓ Tool-verified

Other · Code Health — Whether the work a diagnostic log line costs is paid only when that line is wanted — C# evaluates a call's arguments BEFORE the call, so a trace/debug message joined or projected out of a collection is built in full on every pass, and then discarded by a sink the shipped configuration leaves switched off.

Method: Roslyn syntax: log calls at a diagnostic level (a `Log`-prefixed method naming Trace/Debug/Verbose, or a bare `Debug`/`Trace`/`Verbose` on a receiver named for a logger), whose argument list is read for a call whose cost scales with a sequence — a LINQ operator, a materialisation, `string.Join`, a serializer — with no enclosing level check or conditional-compilation region. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `debug`/`trace`/`verbose` call on a receiver named for a logger, or a `log`-prefixed method naming the level, whose argument calls an array operator (`map`/`filter`/`reduce`/`sort`/…), `Array.from`, `Object.keys/values/entries`, `JSON.stringify`/`util.inspect` over anything but a literal, or an array `join` — outside any arrow or function passed as an argument, which the logger calls only when the level is on — with no enclosing `if`, `&&` or `?:` whose condition names a level, a level string, or the `NODE_ENV`/`__DEV__`/`DEV` build switch. Deterministic, provable per finding. Advisory.

  • `debug` at line 2069 is called with an argument built by `[item.type for item in items_to_save_turn]` (line 2071), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — src/agents/run.py:2069
  • `debug` at line 2555 is called with an argument built by `[id(i) for i in filtered.input]` (line 2558), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — src/agents/run_internal/run_loop.py:2555
  • `debug` at line 280 is called with an argument built by `json.dumps(message.model_dump(), indent = 2, ensure_ascii = False)` (line 282), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — src/agents/models/openai_chatcompletions.py:280
  • `debug` at line 626 is called with an argument built by `x.model_dump()` (line 629), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — src/agents/models/openai_responses.py:626
  • `debug` at line 423 is called with an argument built by `item.model_dump()` (line 426), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — src/agents/extensions/models/any_llm_model.py:423
  • `debug` at line 632 is called with an argument built by `json.dumps(message.model_dump(), indent = 2, ensure_ascii = False)` (line 634), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — src/agents/extensions/models/any_llm_model.py:632
  • `debug` at line 893 is called with an argument built by `json.dumps(converted_messages, indent = 2, ensure_ascii = False)` (line 897), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — src/agents/extensions/models/any_llm_model.py:893
  • `debug` at line 270 is called with an argument built by `json.dumps(message.model_dump(), indent = 2, ensure_ascii = False)` (line 272), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on. — src/agents/extensions/models/litellm_model.py:270

What to do

  • In Python, put the construction behind the logger's own check (`if logger.isEnabledFor(logging.DEBUG):`), or pass the collection itself with a `%s` placeholder (`logger.debug("Items %s", items)`) so the logging module renders it only when the record is emitted. The placeholder alone is not the fix when the argument is still built first: it defers the formatting, not a `json.dumps`, a `join` or a comprehension in the argument, and an f-string defers nothing at all.
X24 · Document value interpolated into markup unescaped10.0 / 10Exemplary○ Nothing flagged

Other · Security — Whether text read out of the document being converted is escaped before it is written into generated markup — a value the document's author chose, interpolated into an attribute the surrounding literal delimits, can close that attribute and open another.

Method: Roslyn semantic model over the whole compilation: a string-typed `Value`/`InnerText`/`InnerXml`/`Text` member declared inside `DocumentFormat.OpenXml` or `System.Xml` is a taint SOURCE, propagated through assignments, returns, arguments, tuple elements and string composition to its transitive closure, then read at interpolated-string holes that sit in a markup position the surrounding literal itself delimits. Escaper/encoder calls and enclosing validator conditions cut the flow. Flow- and container-insensitive by construction. A second arm needs no provenance at all and reports a type that CONTRADICTS ITSELF — the same expression escaped at one delimited markup hole and interpolated raw at another hole in the same markup position of the same type, which the type's own escaping proves is a defect without knowing where the value came from. On a repository with no .NET source it reads JavaScript/TypeScript off the token stream with the same rule: a DOM read of raw document text (`getAttribute`, `textContent`, `innerText`, `nodeValue`) is the source, propagated through local bindings and string composition, and judged at template-literal and concatenation holes in the same two delimited markup positions; escapers and validating conditions cut it, and documentation-site, test, vendored and minified scripts are not read. Deterministic, provable per finding. Advisory.

X25 · Inert configuration knob10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a value the caller is invited to supply is the value the type actually uses — a constructor parameter stored in a private field that nothing ever reads while the default it was given is spelled out a second time at the site that should have read it, a keyed lookup that falls back to a different setting than the one its key names while the same type falls back to the matching one for that same key, or a culture-sensitive parse given no format provider by a type that feeds its own settable culture to the same kind of parse elsewhere, or a number an entry point writes to standard output under the host's culture while the same entry point formats with the invariant culture elsewhere. Either way, every caller who supplies a value silently gets something else.

Method: Roslyn syntax: private instance fields of a non-partial type assigned in a constructor from one of its own parameters with a `??` fallback, checked for whether anything in the type body reads the field and whether that same fallback expression is spelled out again outside the constructor; and `??` fallbacks onto a member access from a lookup call carrying exactly one string literal, grouped by that key across the type and checked for a fallback member whose folded name disagrees with the key while a sibling site for the same key agrees with it. On a repository with no .NET source the first two arms read JavaScript/TypeScript off the engine’s own token stream (tests included, bundles and vendored paths not): a `#x`, `private` or `private` parameter-property instance field filled in the constructor from a parameter (or one member of one) through `??`/`||` or a parameter default, never read anywhere in the file by name, whose constructed default is spelled again in the class body; and `lookup("key") ?? s.member` grouped by key per class, or per module outside every class. The culture arm has no JavaScript counterpart: its parses take no locale. Deterministic, provable per finding. Advisory.

X26 · Unsynchronised callback handoff10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a value handed from a callback to the body that waits on it crosses on something built to be crossed — a `Queue<T>`/`List<T>`/`Dictionary<K,V>` written inside an event handler and read back outside it is mutated by two flows at once, and the semaphore or completion source beside it orders how MANY items exist while leaving the collection's own head, tail and backing array unprotected.

Method: Roslyn syntax: method, accessor, local-function and lambda bodies that declare BOTH a non-thread-safe generic collection (`Queue`/`Stack`/`List`/`Dictionary`/`HashSet`/`Sorted*`/`LinkedList`) and a synchronisation primitive (`SemaphoreSlim`/`TaskCompletionSource`/`ManualResetEvent(Slim)`/`AutoResetEvent`/`CountdownEvent`) as locals, then read for a `+=`-registered lambda that raises that primitive while the body outside every lambda waits on it — and, in that scope, a mutating call on the collection inside the lambda paired with a mention of it outside. Any `lock` in the scope abstains it. On a repository with no .NET source the same handoff is read in Java off the engine’s own token stream (test source sets, vendored and demonstration paths not): an `ArrayList`/`LinkedList`/`ArrayDeque`/`PriorityQueue`/`Hash*`/`LinkedHash*`/`Tree*` local and a `CountDownLatch`/`Semaphore`/`CompletableFuture` local, a lambda or anonymous class that raises the primitive and mutates the collection, and a wait outside it; any `synchronized` or `lock()` abstains the body. Because each of those primitives orders what the callback wrote before raising it, only a touch that provably overlaps the callback is convicted: one after the registration and before the next wait, or one in a loop registered-before, waiting on every pass and not declaring the collection. Deterministic, provable per finding. Advisory.

X27 · Collection changed while being enumerated10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a `for` loop leaves the `dict`, `set` or `deque` it is walking alone — CPython's iterators over those check that the collection has not changed size since the loop began, so a body that removes from (or empties) the very collection the loop is walking makes the next step raise `RuntimeError: dictionary changed size during iteration` and the remaining items are never seen.

Method: Roslyn syntax + semantics: `foreach` statements whose body calls a structural mutator (`Add`/`Remove`/`Clear`/`Insert`/…) on the very expression the loop is enumerating. Two arms. ARM A — the source is a concrete fragile BCL collection, or a live `Keys`/`Values` view over one, and the mutator resolves to that same collection's own member; concurrent and immutable collections and arrays are outside the population by construction, since their enumerators survive a structural change. ARM B — the source is an argument-less accessor CALL on a receiver whose body is in source: the accessor must return a stored field VERBATIM and a sibling member must structurally change that same field, both read off the implementations rather than from the members' names. A mutation the loop provably exits immediately after (`break`/`return`/`throw`/`goto`), or one written inside a nested loop or a lambda, is counted and never reported. Deterministic, provable per finding. Advisory.

X28 · Index access outside its own emptiness guard10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a condition that tests a value for emptiness indexes that same value only where the test holds — an `||` written one parenthesis too far to the left leaves an index access outside the guard beside it, so the empty case the guard exists to anticipate reaches the index and throws.

Method: Roslyn syntax only, no semantic model: the OUTERMOST `&&`/`||` of every boolean condition, read for a symbol the condition tests for emptiness (`string.IsNullOrEmpty`/`IsNullOrWhiteSpace`, a `Length`/`Count` comparison against a literal, `Any()`, a `Length`/`Count` pattern, or a comparison against `""`) and ALSO indexes. Each `symbol[...]` access is placed by a boolean-reachability walk from the access up to the outermost connective: an access is COVERED when some enclosing step has it in the right operand and the left operand, under the truth value that step forces, proves the symbol non-empty — a recursion over `&&`/`||` whose true- and false-directions are asymmetric. A finding needs BOTH an uncovered access and a covered one on the same symbol in the same condition, which is the agreeing twin that separates a misplaced parenthesis from an unrelated length test. Bare index accesses with no emptiness test in the condition are neither counted nor reported; a non-identifier receiver and a lambda nested inside the condition are outside the population. Deterministic, provable per finding. Advisory.

X3 · Exception handling5.3 / 10Adequate✓ Tool-verified

Other · Code Health — Whether exceptions are handled rather than silently swallowed or rethrown with lost stack traces.

Method: Roslyn syntax scan: every catch clause counted; empty catches and bare rethrows flagged. Population is all catch clauses, not estimated. Deterministic, hard fact.

  • `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. (×23) — src/agents/_tool_identity.py:281, src/agents/_tool_identity.py:310, src/agents/agent_tool_state.py:64, …
  • `except BaseException` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter. (×9) — src/agents/exceptions.py:71, src/agents/exceptions.py:86, src/agents/exceptions.py:121, …
  • An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it. (×8) — src/agents/exceptions.py:210, src/agents/exceptions.py:224, src/agents/exceptions.py:287, …

What to do

  • Swallowed exception (caught, then discarded)
X30 · Support guard that admits what it rejects10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether a guard written as a NEGATED `||` says what its author meant — `!(a || b || x != k)` is `!a && !b && x == k` by De Morgan, so a bail-out that mixes capabilities the code needs with a fault it refuses turns inside out: it fires only where the capabilities are ABSENT, and lets every value the fault term names walk straight into the body that cannot handle it.

Method: Roslyn syntax only, no semantic model: every logical-not whose operand is a parenthesised `||` chain of two or more disjuncts, flattened (a left-nested `a || b || c` read once would see `(a || b)` as one disjunct). A site enters the population on that shape alone. A finding additionally needs the disjuncts to DISAGREE in polarity: at least one bare boolean read — an identifier or member access, never an invocation, which is a predicate rather than a capability flag — and at least one `x != <constant>`, the only form that negates into an exact-value pin (`== null` negates into a looser requirement and is outside the fault set). Consistently-polarised disjunctions, all-fault or all-capability, are counted and never reported; a negated `&&` is outside the population entirely. No same-receiver gate: it was measured to cost a real defect and remove no false positive. Deterministic, provable per finding. Advisory.

X4 · Structured logging10.0 / 10Exemplary○ Nothing flagged

Other · Code Health — Whether log calls use message templates (queryable) rather than interpolated strings.

Method: Roslyn syntax scan: every log call-site counted; interpolated-string first-argument violations flagged. Population is all log calls, not estimated. On a repository with no .NET source it reads JavaScript/TypeScript off the engine’s own token stream (test, vendored and minified paths not) with the same rule: a `trace`/`debug`/`info`/`warn`/`error`/`fatal`/`verbose`/`silly`/`http`/`log` call on a receiver named for a logger, in a package whose own or an enclosing `package.json` declares a logger that carries values as fields (pino, pino-http, nestjs-pino, Fastify, winston, bunyan, tslog, LogTape, roarr), whose first deciding argument is a template literal with substitutions; an object-literal fields argument is stepped over, a plain string message clears the call. Python is read the same way: a `debug`/`info`/`warning`/`error`/`exception`/`critical`/`log` call on a logger in a file that imports the standard library’s `logging` or structlog (loguru, which formats at the call, is not judged), whose message is a whole f-string with a non-constant field; a `%`-formatted, `.format()`-ed or concatenated message is not convicted, as in C#. PHP is read the same way: a PSR-3 level call (`emergency`…`debug`, `log`) on a logger (`$logger`, `$this->logger`, Laravel’s `Log::`, `logger()`, `\Drupal::logger()`) in a package whose `composer.json` requires a PSR-3 logger or a framework that hands one out (psr/log, Monolog, Laravel, Symfony, Drupal, CakePHP), or a file that imports one, whose message is a double-quoted string interpolating a variable; a single-quoted message clears the call, and `sprintf` or `.` concatenation is not convicted, as in C#. Dart is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on Sentry’s structured logger (`Sentry.logger`) whose message is a whole string literal interpolating a value (`$name`, `${…}`); the `Sentry.logger.fmt` template API clears the call. Dart that logs only through loggers with one message and no fields (package:logging, package:logger, talker, dart:developer) is not applicable rather than a reach gap. Ruby is read the same way: a `trace`/`debug`/`info`/`warn`/`error`/`fatal` call on the console gem’s `Console` (declared by a Gemfile, gemspec or Gemfile.lock, or required) or, where SemanticLogger, Ougai or dry-logger is declared or required, on a receiver named for a logger (`logger`, `@logger`, `Rails.logger`, `log`), whose first deciding argument is, as the whole argument, a double-quoted string interpolating a non-constant value (`#{…}`, `#@ivar`); a plain literal clears the call, keyword arguments are the fields, and a block, `%`-format or `+` concatenation is not convicted. Ruby that logs only through the standard Logger (Rails.logger) is not applicable rather than a reach gap. Deterministic.

Reference — by lens

The score is the rank-weighted fold of these lenses (worst-heaviest), each including its meta-dimensions; a lens with a Critical contributor is capped at Fair (its band reads "gated by …") and is never the strongest area however high its average.

LensScoreRatingImpact
Code Health74%Adequate — gated by D1, D2Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Architecture89%Adequate — gated by D26Capped at Fair by a Critical contributor — resolve it before relying on this lens.
Maturity76%StrongSolid.
Readiness81%StrongSolid.
Security91%ExemplarySolid.
Domain Modelling54%AdequateLargest drag on the score — prioritise here.
Performance100%ExemplaryStrongest area.
Unscored — 2 check(s) recorded observations but carry no score

These checks ran and found something, but they do not carry a score — either by design (an advisory check reports evidence rather than grading it) or because they could not be scored here. They are excluded from the score for that reason, not because there was nothing to see.

  • X10 Duplicated predicate — 25 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
  • X7 Silent fallback defaults — 11 observation(s) recorded · Advisory — this card reports evidence and never carries a score.
Not evidenced — 1 control(s) we could not find positive evidence for

These checks grade a working control, and the repository shows no evidence of one. That is deliberately not scored as a zero: a repository cannot show an ops runbook, a database TTL or an infrastructure-side audit log, so absence of evidence here is not evidence the control is missing. It is also not a statement that the check is irrelevant to this codebase — the thing it grades applies; we just could not see it. Excluded from the score either way.

  • P5 DR & Backup — not evidenced — repo shows no backup/RTO/RPO controls; absence of evidence is not evidence of a working control
Not included — 60 check(s) not relevant to this codebase

These checks had nothing to measure here (no tests, no git history, the codebase is small, or the architecture style doesn't apply), so they're omitted above rather than scored low.

  • AC1 Text alternatives — No web markup found — accessibility is not applicable to this repository.
  • AC2 Forms & labels — No web markup found — accessibility is not applicable to this repository.
  • AC3 Page structure — No web markup found — accessibility is not applicable to this repository.
  • AC4 Keyboard semantics — No web markup found — accessibility is not applicable to this repository.
  • AC5 ARIA correctness — No web markup found — accessibility is not applicable to this repository.
  • AC6 Visual & motion safety — No web markup found — accessibility is not applicable to this repository.
  • AC7 A11y enforcement — No web markup found — accessibility is not applicable to this repository.
  • AX1 Captive dependencies — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX2 Stateful singletons — No container singleton was found, so there is no shared instance for concurrent requests to race on. No function in this Python code is served by a threaded web framework (a Flask, Bottle or FastAPI route, a Django or Pyramid view), so no module is shared between request threads. TypeScript/JavaScript runs each process's requests on one event loop, so no two requests write a shared object at the same instant (interleaving across an await is a different defect).
  • AX5 Architecture & structure — not assessed — architecture style/structure is computed from a project graph (projects, types, module namespaces) that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX6 Interface segregation — not assessed — interface segregation is computed over a type surface that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • AX7 Slice cohesion — not applicable — not a vertical-slice architecture
  • AX8 Test isolation — no test/production split to check
  • AX9 CQS / query purity — no CQRS query handlers detected — query purity is not applicable to this codebase
  • AXB2 Runtime readiness — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • AXR1 Runtime accessibility — the image ran but published no HTTP port — nothing to crawl (EXPOSE the web port to unlock runtime evidence) This is a statement about this run, not a statement about your application: nothing here says the surface is inaccessible, only that it was never rendered.
  • C1 Data Protection — Not assessed: these personal data controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks personal data controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • C2 Access Controls — No access-control surface detected in the analyzed source — this repository registers no route and starts no server another machine can reach (no Flask/FastAPI/Starlette route, Django urlpatterns or class-based view, Tornado handler). Access control is therefore N/A here — a library or command-line tool is authorized by the application that serves it, not by itself. If this codebase grows request handlers, the dimension reactivates and a default-deny posture is expected then.
  • C3 Audit Trail — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential in a Django, SQLAlchemy, SQLModel, Peewee, Tortoise or MongoEngine model, a migration or a SQL schema — and no database or data-store client (Django ORM, SQLAlchemy, psycopg, PyMongo, …) in the source either, so this repository keeps no sensitive data whose changes an audit trail would record. If it does (through a store configured outside this repository, for instance), the trail belongs to wherever that data is stored.
  • C4 Data Retention — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential on a Django, SQLAlchemy, SQLModel, Peewee, Tortoise or mongoengine model, in a migration or in a SQL schema — and no database or data-store client (django.db, sqlalchemy, psycopg2, pymongo, sqlite3, …) imported either, so this repository keeps no personal data whose lifetime a retention limit would bound.
  • C5 Data-Subject Rights — No personal data detected in a persisted data model — no PII-named field (email, first_name, date_of_birth, phone, …) or stored credential on a Django, SQLAlchemy, SQLModel, Peewee, Tortoise or mongoengine model, in a migration or in a SQL schema — and no database or data-store client (django.db, sqlalchemy, psycopg2, pymongo, sqlite3, …) imported either, so this repository keeps no personal data for a data subject to erase, export or consent over.
  • D10 Test Quality — ~257834 lines of test source are present (.py) but no test cases reached the test census for this repository — no test root we could resolve declared them, or the files we read declare no cases in a test framework we recognise — so skipped/assertion-free tests couldn't be counted. Not scored — this is a gap in the analyzer, not a finding about this repository.
  • D12 Dependency Hygiene — Dependency currency not established — no declaration carries an exact pin to grade
  • D18 Solution Shape — D18 scores the shape of a .NET solution; this repository has no .NET solution or project files, so the dimension does not apply.
  • D20 ADR Quality — N/A — ADRs are expected on deployable products with a user-facing host, not consumed libraries; no ADR log is required here.
  • D21 Naming Consistency — Naming consistency is measured on C# and TypeScript only; JavaScript, Python not measured.
  • D22 Internal API Consistency — API consistency is measured on C# only; the exposed Python surface was not measured.
  • D23 Boundary Type-Coupling — No bounded-context organisation was detected either — neither a context-shaped layout, nor 2+ sibling source directories each declaring an aggregate root, nor 2+ sibling projects each declaring an entity of their own or taking another project's integration events. Aggregate roots were found in only one source directory (examples), which is a layered codebase, not two contexts. Declaring this codebase's bounded contexts (≥2) would let cross-boundary type coupling be assessed. Declare them in `.codehealth/config.yaml` at the repository root (create it if absent), mapping each context name to the module-path or namespace prefixes that belong to it — e.g. `architecture:` → `contexts:` → `Billing: ["src/billing", "Acme.Billing"]`, `Catalog: ["src/catalog", "Acme.Catalog"]`.
  • D24 Comment Value — D24 reads C#, Visual Basic, TypeScript and JavaScript comments only; comments in this repository's .py source were not judged.
  • D25 ADR Conformance — no ADRs to check
  • D32 Data Compliance (PII/GDPR) — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that.
  • D39 IL Efficiency — D39 measures the IL emitted by a .NET build; this repository has no .NET solution or project files, so the dimension does not apply.
  • D40 Network Egress Confinement — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.
  • D41 Kernel & Syscall Confinement — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.
  • D42 Runtime Threat Enforcement — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.
  • D5 Coupling — Not applicable — this Python build ships 1 production module(s), so there is no coupling BETWEEN modules to measure. (Its test and non-production modules are not part of the shipped graph.)
  • D7 Architectural Integrity — no checkable ADRs, and no project-reference graph for the cycle pass to read — so this dimension makes no claim about dependency cycles in either direction (where this repository's language has an import-cycle lens, cycles are reported there). Architectural integrity not assessed
  • D8 Code Coverage — Coverage not included — suite not readable by the collector
  • ED1 Event-Driven — not scored — this repository shows none of the 3 signals this lens looks for
  • ED5 Idempotency — no mutating command handlers or message consumers detected — idempotency check not applicable
  • ES1 Event Sourcing — not scored — this repository shows none of the 3 signals this lens looks for
  • GD1 Unfinished & placeholder code — no source files were read — this check reads C#, F#, JavaScript/TypeScript, Dart, Ruby and Scala, and none was read for this repository's product. That is a limit of the analyzer, not a finding about your code.
  • IC1 Incompleteness & stubs — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • M4 Documentation accuracy — Not applicable: the 200 current-state document(s) make no claim of a kind M4 checks. 107 claim(s) of kinds M4 does not check were not checked (path 26, environment variable 81); M4 checks only links and versions and artefact counts.
  • P12 CI test-gate honesty — Reported, not scored — this card publishes what the CI gate does with the test inventory rather than grading it. The findings above are its output.
  • P7 Outbound HTTP resilience — not applicable — no HTTP server, API framework or worker entry point was found in the Python source, so there is no service whose uptime a failing dependency could take down
  • P8 Schema migrations — SQLAlchemy is declared, but the schema-migration mechanism could not be identified. Our limit, not a verdict on this repository.
  • P9 Domain vs controller coverage — no coverage report found on disk — produce a coverage report in a standard format (`coverage run -m pytest` then `coverage xml`) and commit it — a hosted scan measures a clone of the repository, so a report that exists only in a working tree, a CI runner's or your own, never reaches it; the artefact is commonly gitignored, so `git add -f` that one file (or un-ignore its path) and commit it alongside the code it measures, or wire coverage collection into CI, to enable this cross-layer check
  • PF1 Benchmark discipline — Not applicable: no benchmark suite was found. This check searched for a pytest-benchmark or pytest-codspeed dependency with tests taking the `benchmark` fixture, an asv.conf.json with its `time_`/`mem_`/`peakmem_` benchmarks, or a pyperf Runner, and for a `*benchmark*` script that this repository's CI runs. Benchmarks are credited as a bonus, so their absence is neither scored nor deducted.
  • PF2 Allocation hygiene — Not applicable: Python runs on a garbage-collected runtime that gives a program no allocation-control idiom to choose on a hot path — no pools, stack allocation or value types — so allocation awareness is not something this code can be rated on.
  • S1 Web-Security Posture — Not assessed: these web-security controls are read from a source model (declarative annotations, request middleware, entity/column names, guard methods) that was not loaded for this repository — because the repository is written in a language this check does not yet model, or because its projects failed to load. Absence of an idiom this check recognises is NOT evidence that this repository lacks web-security controls: it may implement them entirely in its own ecosystem. This is a gap in the analyzer's language coverage, not a finding about this repository.
  • X16 Unfloored truncation loop — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X18 Disposal-pattern correctness — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X2 Cancellation propagation — no C# was loaded; this repository's Python was read, and no request in it can be cancelled by a caller — a Python request takes no token: asyncio cancels the task and trio or anyio the scope that made it, from outside the call, and requests, httpx, aiohttp and gRPC take a timeout, not a cancellation
  • X20 Mistyped argument guard — This check asks whether an argument guard reports an EMPTY value as a NULL one, which needs a language that throws a null-specific argument exception — .NET's ArgumentNullException, the JVM's NullPointerException, Dart's ArgumentError.notNull. This repository contains none of those languages: the ones it is written in have a single exception for a bad argument, so there is no pair of exceptions to confuse and nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X29 Per-element action decided by a fixed element — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X32 Type resolved by simple name across every loaded assembly — This check is about how a .NET program searches the assemblies loaded into its process for a type, and this repository contains no .NET source, so there is nothing here for it to assess. Not a gap in the analyzer and not a finding about your code.
  • X5 Nullable reference types — not analysed — these correctness checks read a source model that was not loaded for this repository, because the repository is written in a language this check does not yet model, or because its projects failed to load. This is a gap in the analyzer, not a finding about this repository
  • X6 Hand-rolled structured-format parsing — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.
  • X9 Subsumed condition operand — Advisory — this card reports evidence and never carries a score, so there is nothing missing here.

Appendix A — Findings (grouped)

The findings behind the scores, grouped by severity, then by dimension and kind. The high-severity issues are enumerated in full below; items per group are capped at 25 with any overflow stated explicitly per group, never silently truncated. The complete machine-readable list of every finding (all severities) is the companion findings.md in this report's bundle.

Critical — 4 finding(s)
D30 · Dependency Vulnerabilities · High CVE · ×2
  • REDACTED
  • REDACTED
D30 · Dependency Vulnerabilities · Critical CVE · ×1
  • REDACTED
DM6 · Domain ↔ infrastructure boundary · Domain fused to persistence infrastructure · ×1
  • Domain fused to persistence infrastructure: OpenAIHostedMultiAgentModel src/agents/extensions/experimental/hosted_multi_agent/model.py:369 — `OpenAIHostedMultiAgentModel` is a domain concept fused to persistence ON ITS OWN DECLARATION (Django/SQLAlchemy — `models.Model`/`db.Model`) — the domain entity IS the ORM row (active-record), and it carries domain behaviour on the persistence type. A schema/persistence change ripples straight into the domain. Keep the ORM/table mapping on a boundary data-model + a mapper, and the domain entity framework-free (map row↔domain through a repository).
Serious — 752 finding(s)
D15 · Churn × Complexity Hotspots · Hotspot · ×46
  • Hotspot: src/agents/run.py src/agents/run.py:629 — src/agents/run.py changed 25 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 239 in AgentRunner._run_impl at line 629. 22 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/run.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/run_internal/run_loop.py src/agents/run_internal/run_loop.py:987 — src/agents/run_internal/run_loop.py changed 28 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 201 in run_loop.start_streaming at line 987. 24 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/run_internal/run_loop.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/run_state.py src/agents/run_state.py:4174 — src/agents/run_state.py changed 39 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 115 in run_state._build_run_state_from_json at line 4174. 33 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/run_state.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/run_internal/turn_resolution.py src/agents/run_internal/turn_resolution.py:1387 — src/agents/run_internal/turn_resolution.py changed 18 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 170 in turn_resolution.resolve_interrupted_turn at line 1387. 16 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/run_internal/turn_resolution.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/models/chatcmpl_stream_handler.py src/agents/models/chatcmpl_stream_handler.py:603 — src/agents/models/chatcmpl_stream_handler.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 129 in ChatCmplStreamHandler.handle_stream at line 603. 9 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/models/chatcmpl_stream_handler.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/memory/openai_responses_compaction_session.py src/agents/memory/openai_responses_compaction_session.py:273 — src/agents/memory/openai_responses_compaction_session.py changed 18 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 60 in OpenAIResponsesCompactionSession._run_compaction_locked at line 273. 18 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/memory/openai_responses_compaction_session.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: integration_tests/_contract_support.py integration_tests/_contract_support.py:208 — integration_tests/_contract_support.py changed 13 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 80 in _contract_support.build_released_api_contract at line 208. 9 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- integration_tests/_contract_support.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/realtime/session.py src/agents/realtime/session.py:412 — src/agents/realtime/session.py changed 14 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 59 in RealtimeSession.on_event at line 412. 14 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/realtime/session.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/run_internal/session_persistence.py src/agents/run_internal/session_persistence.py:1444 — src/agents/run_internal/session_persistence.py changed 19 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 41 in session_persistence.resume_pending_session_write at line 1444. 18 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/run_internal/session_persistence.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/models/openai_responses.py src/agents/models/openai_responses.py:2252 — src/agents/models/openai_responses.py changed 17 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 34 in Converter._convert_tool at line 2252. 11 of those changes were fix/bug commits, so the churn is repair rather than feature work. Before the next change lands here, make sure the area it touches is under test, then split that area out of the file so the following change is smaller than this one — a file this often edited pays the complexity back every time. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/models/openai_responses.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/run_context.py src/agents/run_context.py:1369 — src/agents/run_context.py changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 60 in RunContextWrapper.get_approval_status at line 1369. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/run_context.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/models/chatcmpl_converter.py src/agents/models/chatcmpl_converter.py:548 — src/agents/models/chatcmpl_converter.py changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 75 in Converter.items_to_messages at line 548. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/models/chatcmpl_converter.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/realtime/openai_realtime.py src/agents/realtime/openai_realtime.py:1370 — src/agents/realtime/openai_realtime.py changed 8 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 58 in OpenAIRealtimeWebSocketModel._handle_ws_event at line 1370. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/realtime/openai_realtime.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/extensions/models/any_llm_model.py src/agents/extensions/models/any_llm_model.py:846 — src/agents/extensions/models/any_llm_model.py changed 15 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 30 in AnyLLMModel._fetch_chat_response at line 846. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/extensions/models/any_llm_model.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/function_schema.py src/agents/function_schema.py:321 — src/agents/function_schema.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 45 in function_schema.function_schema at line 321. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/function_schema.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/run_internal/tool_execution.py src/agents/run_internal/tool_execution.py:1402 — src/agents/run_internal/tool_execution.py changed 13 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 29 in tool_execution.collect_manual_mcp_approvals at line 1402. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/run_internal/tool_execution.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: .agents/skills/implementation-final-review/scripts/review_protocol.py .agents/skills/implementation-final-review/scripts/review_protocol.py:526 — .agents/skills/implementation-final-review/scripts/review_protocol.py changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 109 in review_protocol.validate_packet at line 526. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- .agents/skills/implementation-final-review/scripts/review_protocol.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: REDACTED REDACTED:686 — REDACTED changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 34 in MCPUtil.invoke_mcp_tool at line 686. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- REDACTED`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/mcp/server.py src/agents/mcp/server.py:2550 — src/agents/mcp/server.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 30 in MCPServerStreamableHttp.call_tool at line 2550. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/mcp/server.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/result.py src/agents/result.py:1172 — src/agents/result.py changed 16 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 18 in RunResultStreaming._check_errors at line 1172. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/result.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/models/openai_chatcompletions.py src/agents/models/openai_chatcompletions.py:605 — src/agents/models/openai_chatcompletions.py changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 26 in OpenAIChatCompletionsModel._fetch_response at line 605. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/models/openai_chatcompletions.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/strict_schema.py src/agents/strict_schema.py:156 — src/agents/strict_schema.py changed 6 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 44 in strict_schema._ensure_strict_json_schema at line 156. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/strict_schema.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/voice/models/openai_stt.py src/agents/voice/models/openai_stt.py:320 — src/agents/voice/models/openai_stt.py changed 12 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 21 in OpenAISTTTranscriptionSession._handle_events at line 320. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/voice/models/openai_stt.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/sandbox/sandboxes/docker.py src/agents/sandbox/sandboxes/docker.py:1695 — src/agents/sandbox/sandboxes/docker.py changed 12 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 21 in DockerSandboxClient.delete at line 1695. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/sandbox/sandboxes/docker.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Hotspot: src/agents/sandbox/_mount_security.py src/agents/sandbox/_mount_security.py:1131 — src/agents/sandbox/_mount_security.py changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 49 in _mount_security._call_has_configured_mount_authority at line 1131. Frequent change and high complexity in one file compound: schedule the next change to it to include carving out the part being edited, with the area under test before it moves. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/sandbox/_mount_security.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • + 21 more in this group — see findings.md.
D3 · God Classes · FileTooLong · ×37
  • FileTooLong: agents/run_state.py src/agents/run_state.py — FileTooLong — 4253 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3753 over it, 8.51× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: run_internal/turn_resolution.py src/agents/run_internal/turn_resolution.py — FileTooLong — 3367 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 2867 over it, 6.73× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: run_internal/run_loop.py src/agents/run_internal/run_loop.py — FileTooLong — 2419 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1919 over it, 4.84× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: run_internal/tool_execution.py src/agents/run_internal/tool_execution.py — FileTooLong — 2251 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1751 over it, 4.50× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: agents/run.py src/agents/run.py — FileTooLong — 2229 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1729 over it, 4.46× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: agents/tool.py src/agents/tool.py — FileTooLong — 1880 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1380 over it, 3.76× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: models/openai_responses.py src/agents/models/openai_responses.py — FileTooLong — 1851 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1351 over it, 3.70× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: mcp/server.py src/agents/mcp/server.py — FileTooLong — 1813 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1313 over it, 3.63× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: realtime/openai_realtime.py src/agents/realtime/openai_realtime.py — FileTooLong — 1685 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1185 over it, 3.37× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: realtime/session.py src/agents/realtime/session.py — FileTooLong — 1673 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1173 over it, 3.35× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: run_internal/session_persistence.py src/agents/run_internal/session_persistence.py — FileTooLong — 1457 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 957 over it, 2.91× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: agents/run_context.py src/agents/run_context.py — FileTooLong — 1395 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 895 over it, 2.79× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: models/any_llm_model.py src/agents/extensions/models/any_llm_model.py — FileTooLong — 1296 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 796 over it, 2.59× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: codex/codex_tool.py src/agents/extensions/experimental/codex/codex_tool.py — FileTooLong — 1151 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 651 over it, 2.30× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: scripts/review_protocol.py .agents/skills/implementation-final-review/scripts/review_protocol.py — FileTooLong — 1148 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 648 over it, 2.30× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: run_internal/tool_planning.py src/agents/run_internal/tool_planning.py — FileTooLong — 1022 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 522 over it, 2.04× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: models/chatcmpl_stream_handler.py src/agents/models/chatcmpl_stream_handler.py — FileTooLong — 1003 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 503 over it, 2.01× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: testing/model.py src/agents/testing/model.py — FileTooLong — 967 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 467 over it, 1.93× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: run_internal/items.py src/agents/run_internal/items.py — FileTooLong — 884 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 384 over it, 1.77× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: run_internal/tool_actions.py src/agents/run_internal/tool_actions.py — FileTooLong — 853 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 353 over it, 1.71× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: agents/result.py src/agents/result.py — FileTooLong — 847 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 347 over it, 1.69× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: memory/advanced_sqlite_session.py src/agents/extensions/memory/advanced_sqlite_session.py — FileTooLong — 829 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 329 over it, 1.66× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: hosted_multi_agent/model.py src/agents/extensions/experimental/hosted_multi_agent/model.py — FileTooLong — 805 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 305 over it, 1.61× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: agents/agent.py src/agents/agent.py — FileTooLong — 779 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 279 over it, 1.56× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • FileTooLong: models/chatcmpl_converter.py src/agents/models/chatcmpl_converter.py — FileTooLong — 776 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 276 over it, 1.55× the bar. To reduce it, split the file along the responsibilities already in it: move each cohesive group of declarations into its own sibling file in the same module or package, so no one file has to be read whole to change one of them.
  • + 12 more in this group — see findings.md.
X3 · Exception handling · Swallowed exception (caught, then discarded) · ×32
  • Swallowed exception (caught, then discarded) src/agents/_tool_identity.py:281 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/_tool_identity.py:310 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/agent_tool_state.py:64 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/agent_tool_state.py:69 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/exceptions.py:71 — `except BaseException` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/exceptions.py:86 — `except BaseException` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/exceptions.py:121 — `except BaseException` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/exceptions.py:244 — `except BaseException` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/logger.py:27 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run.py:231 — `except BaseException` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run.py:775 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run.py:1719 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_context.py:302 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_state.py:1164 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_state.py:1168 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_state.py:2821 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_state.py:3351 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_state.py:3374 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_state.py:3432 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_state.py:3644 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_state.py:3650 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_state.py:3658 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_state.py:3843 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_state.py:5660 — `except BaseException` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • Swallowed exception (caught, then discarded) src/agents/run_internal/agent_runner_helpers.py:178 — `except Exception` takes every exception and records none of it — the body neither logs it, rethrows it, nor even names it, so the failure is discarded as completely as by an empty catch and only the substituted value survives. Log it through whatever this codebase already uses to report problems, narrow the catch to the exception this call can actually raise, or say in a comment on the catch why the failure genuinely cannot matter.
  • + 7 more in this group — see findings.md.
D15 · Churn × Complexity Hotspots · Repeated repair · ×20
  • Repeated repair: src/agents/run_internal/agent_runner_helpers.py src/agents/run_internal/agent_runner_helpers.py:132 — src/agents/run_internal/agent_runner_helpers.py changed 10 times in last 90 days and 8 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 11 (its worst body is agent_runner_helpers.attach_usage_to_span at line 132), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: preserve tool outputs after callback failures (#5318)”; “fix(sessions): persist deferred approval history across resumes (#4828)”; “fix(sessions): recover fresh streamed handoffs after session append failures (#4835)”; “fix(core): deliver tool-not-found output on server-managed resume (#4947)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/run_internal/agent_runner_helpers.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/sandbox/session/base_sandbox_session.py src/agents/sandbox/session/base_sandbox_session.py:834 — src/agents/sandbox/session/base_sandbox_session.py changed 8 times in last 90 days and 7 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 13 (its worst body is BaseSandboxSession._validate_remote_path_access at line 834), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: keep the file when apply_patch does a case-only rename (#4890)”; “fix(sandbox): preserve symlink targets during snapshot restore (#5208)”; “fix(sandbox): scope exclusive Add File creation to UnixLocal (#4893)”; “fix(sandbox): enforce grants during recursive removal (#5206)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/sandbox/session/base_sandbox_session.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/memory/sqlite_session.py src/agents/memory/sqlite_session.py:538 — src/agents/memory/sqlite_session.py changed 7 times in last 90 days and 7 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 11 (its worst body is SQLiteSession.close at line 538), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(memory): preserve encrypted SQLite history on wrong-key pops (#5083)”; “fix(sessions): close SQLiteSession connections owned by exited worker threads (#5090)”; “fix(extensions): preserve filtered history during automatic compaction (#5103)”; “fix(sessions): settle conversation deletion before propagating cancellation (#4790)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/memory/sqlite_session.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/exceptions.py src/agents/exceptions.py:192 — src/agents/exceptions.py changed 8 times in last 90 days and 6 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 14 (its worst body is exceptions._prepare_data_redacted_error at line 192), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: preserve completed tool outputs when a sibling fails (#5332)”; “fix: preserve caller-owned exceptions during sandbox redaction (#5367)”; “fix: max-turn handler session semantics (#4412)”; “fix: preserve sandbox error contracts during mount redaction (#4344)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/exceptions.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/items.py src/agents/items.py:845 — src/agents/items.py changed 8 times in last 90 days and 6 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 13 (its worst body is ItemHelpers.tool_call_output_item at line 845), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: preserve completed tool outputs when a sibling fails (#5332)”; “fix(core): strip created_by when replaying RunItems as input (#4568)”; “fix: detach RunState interruption snapshots (#4409)”; “fix(items): strip output-only created_by when replaying model output as input (#4308)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/items.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/run_internal/tool_actions.py src/agents/run_internal/tool_actions.py:226 — src/agents/run_internal/tool_actions.py changed 6 times in last 90 days and 5 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 13 (its worst body is ComputerAction._execute_action_and_capture at line 226), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: preserve empty structured shell results (#5423)”; “fix: preserve completed tool outputs when a sibling fails (#5332)”; “fix(core): scope function tool approvals to their owning agent (#5144)”; “Fix falsy optional reference handling (#4305)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/run_internal/tool_actions.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/memory/openai_conversations_session.py src/agents/memory/openai_conversations_session.py:92 — src/agents/memory/openai_conversations_session.py changed 5 times in last 90 days and 5 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 7 (its worst body is OpenAIConversationsSession._get_items at line 92), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: batch OpenAI conversation session writes within the API limit (#5334)”; “fix(sessions): do not forward session limit as Conversations page size (#4961)”; “fix(sessions): settle conversation deletion before propagating cancellation (#4790)”; “fix(sessions): handle zero conversation history limits (#4365)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/memory/openai_conversations_session.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/sandbox/capabilities/tools/apply_patch_tool.py src/agents/sandbox/capabilities/tools/apply_patch_tool.py:337 — src/agents/sandbox/capabilities/tools/apply_patch_tool.py changed 5 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 11 (its worst body is apply_patch_tool._parse_apply_patch_input at line 337), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: preserve embedded separators in sandbox patches (#5365)”; “fix(sandbox): check sandbox apply_patch approval scope (#5146)”; “fix(sandbox): require apply_patch update hunks (#4470)”; “fix(sandbox): normalize apply_patch paths as POSIX (#4437)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/sandbox/capabilities/tools/apply_patch_tool.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/run_internal/run_steps.py src/agents/run_internal/run_steps.py:242 — src/agents/run_internal/run_steps.py changed 5 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 2 (its worst body is SingleStepResult.generated_items at line 242), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: preserve tool outputs after callback failures (#5318)”; “fix(sessions): persist deferred approval history across resumes (#4828)”; “fix(mcp): bind resumed MCP calls to their original recipients (#5119)”; “fix(core): align conditional approvals with validated tool arguments (#5066)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/run_internal/run_steps.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/voice/models/openai_model_provider.py src/agents/voice/models/openai_model_provider.py:82 — src/agents/voice/models/openai_model_provider.py changed 5 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 5 (its worst body is OpenAIVoiceModelProvider._get_client at line 82), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: use gpt-transcribe as the default voice STT model (#5276)”; “fix(core/voice): honor OpenAI provider options over default clients (#4530)”; “fix(voice) reject ignored explicit-client options (#4527)”; “Fix falsy optional reference handling (#4305)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/voice/models/openai_model_provider.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/sandbox/apply_patch.py src/agents/sandbox/apply_patch.py:68 — src/agents/sandbox/apply_patch.py changed 5 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 10 (its worst body is WorkspaceEditor.apply_operation at line 68), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: keep the file when apply_patch does a case-only rename (#4890)”; “fix(sandbox): scope exclusive Add File creation to UnixLocal (#4893)”; “fix(sandbox): normalize apply_patch paths as POSIX (#4437)”; “fix(sandbox): keep move_to when coercing apply_patch operation mappings (#4242)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/sandbox/apply_patch.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/util/_asyncio_tasks.py src/agents/util/_asyncio_tasks.py:97 — src/agents/util/_asyncio_tasks.py changed 4 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 14 (its worst body is _asyncio_tasks.gather_with_cancel at line 97), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: stop native tool queues during function failure cleanup (#5446)”; “fix: preserve completed tool outputs when a sibling fails (#5332)”; “fix: avoid awaiting cleanup during coroutine closure (#5163)”; “fix(core): bound agent tool streaming callback backlogs (#5106)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/util/_asyncio_tasks.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/sandbox/sandboxes/_unix_local_file_ops.py src/agents/sandbox/sandboxes/_unix_local_file_ops.py:63 — src/agents/sandbox/sandboxes/_unix_local_file_ops.py changed 4 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 9 (its worst body is _FileOps._open_regular_file at line 63), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: keep the file when apply_patch does a case-only rename (#4890)”; “fix(sandbox): scope exclusive Add File creation to UnixLocal (#4893)”; “fix(sandbox): add opt-in bounded workspace outbox reads (#5128)”; “fix(sandbox): reject special files in shared UnixLocal file I/O (#5177)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/sandbox/sandboxes/_unix_local_file_ops.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/voice/pipeline.py src/agents/voice/pipeline.py:31 — src/agents/voice/pipeline.py changed 4 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 6 (its worst body is VoicePipeline.__init__ at line 31), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(voice): honor pipeline tracing opt-out inside caller traces (#5120)”; “fix(voice): wake stream when producer is cancelled (#4825)”; “fix(voice): report transcription session close failures to the consumer (#4343)”; “fix(voice): end a streamed session that produced no audio (#4259)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/voice/pipeline.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/voice/input.py src/agents/voice/input.py:16 — src/agents/voice/input.py changed 4 times in last 90 days and 4 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 13 (its worst body is input._buffer_to_audio_file at line 16), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(voice): reject non-positive audio frame rates (#4382)”; “fix(voice): reject non-positive audio channels (#4372)”; “fix(voice): reject incomplete multichannel audio frames (#4370)”; “fix(voice): honor WAV sample width (#4361)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/voice/input.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: .github/scripts/update_released_api_contract.py .github/scripts/update_released_api_contract.py:66 — .github/scripts/update_released_api_contract.py changed 5 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is update_released_api_contract.main at line 66), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: enforce public type alias contract coverage (#4595)”; “fix: freeze public testing API state contracts (#4404)”; “fix: make release API contract promotion policy-driven (#4349)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- .github/scripts/update_released_api_contract.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/sandbox/capabilities/tools/shell_tool.py src/agents/sandbox/capabilities/tools/shell_tool.py:226 — src/agents/sandbox/capabilities/tools/shell_tool.py changed 4 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 7 (its worst body is ExecCommandTool._run at line 226), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: recover from invalid sandbox tool arguments (#5321)”; “fix(sandbox): preserve workdir for shell command lists (#4915)”; “fix(sandbox): keep model paths POSIX-normalized (#4416)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/sandbox/capabilities/tools/shell_tool.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/sandbox/capabilities/tools/view_image.py src/agents/sandbox/capabilities/tools/view_image.py:24 — src/agents/sandbox/capabilities/tools/view_image.py changed 4 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 12 (its worst body is view_image._detect_image_mime_type at line 24), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix: recover from invalid sandbox tool arguments (#5321)”; “fix(sandbox): validate view_image raster content (#4462)”; “fix(sandbox): honor view_image extra path grants (#4417)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/sandbox/capabilities/tools/view_image.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/models/openai_provider.py src/agents/models/openai_provider.py:243 — src/agents/models/openai_provider.py changed 4 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 10 (its worst body is OpenAIProvider.get_model at line 243), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(core/voice): honor OpenAI provider options over default clients (#4530)”; “fix(core): reject ignored explicit-client options for OpenAIProvider (#4497)”; “Fix falsy optional reference handling (#4305)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/models/openai_provider.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
  • Repeated repair: src/agents/extensions/memory/async_sqlite_session.py src/agents/extensions/memory/async_sqlite_session.py:102 — src/agents/extensions/memory/async_sqlite_session.py changed 3 times in last 90 days and 3 of those changes were fix/bug commits, so repair is the majority of this file's churn. Its max cyclomatic complexity is 14 (its worst body is AsyncSQLiteSession._get_connection at line 102), UNDER the 15 threshold, so this is deliberately not filed as a churn × complexity hotspot — the difficulty here is in the behaviour the file has to get right, not in its control flow, and refactoring it for complexity would be the wrong move. The repairs counted were: “fix(extensions): preserve filtered history during automatic compaction (#5103)”; “fix(extensions): handle concurrent async SQLite startup (#4987)”; “fix: make session mutations atomic (#4212)”. Each one is a case this code did not handle. Before the next change lands here, check that every one of them is pinned by a test that fails without its fix; where the same area keeps coming back, the durable fix is usually at the interface that keeps being misused rather than at the line that was last corrected. Counted over 2026-08-05..2026-11-03, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-05 23:17:39 +00:00' --until='2026-11-03 23:17:39 +00:00' --full-history --no-merges -- src/agents/extensions/memory/async_sqlite_session.py`: merges are excluded because a merge re-states changes already counted at their own commits, and history is NOT path-simplified because a change that reached the file through a merged branch is still a change to it. That command counts raw commits and can read HIGHER than this row, which counts a cherry-picked re-land, and a revert together with the commit it undoes, once each — a difference of several commits on a file whose history was re-landed or reverted inside the window.
D17 · Explicit Debt · TodoComment · ×11
  • TodoComment src/agents/model_settings.py:160 — # TODO: revisit ResponseIncludable | str if ResponseIncludable covers more cases — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment src/agents/sandbox/manifest.py:84 — # TODO (sdcoffey) env val from secret store — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment REDACTED:341 — # TODO: thinking about using proxy instead of direct http call — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment src/agents/sandbox/memory/phase_one.py:68 — # TODO: Replace this fixed cap with 70% of the phase-one model's effective — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment src/agents/run_internal/turn_resolution.py:2437 — # TODO: Persist Agent.as_tool() owner identity so replacement before RunState — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment src/agents/realtime/config.py:306 — # TODO (rm) Add history audio storage config — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment src/agents/realtime/openai_realtime.py:468 — # TODO: Remove this once generated Realtime server event models accept custom voice objects. — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment src/agents/realtime/openai_realtime.py:1415 — # TODO (rm) remove — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment src/agents/realtime/session.py:1538 — # TODO (rm) Add support for audio storage config — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment src/agents/realtime/session.py:1716 — # TODO (rm) Remove this cast, it's wrong — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
  • TodoComment src/agents/models/openai_responses.py:1867 — # TODO: revisit the type: ignore comment when ToolChoice is updated in the future — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
D4 · Code Duplication · Duplicated block (9 lines × 2) · ×11
  • Duplicated block (9 lines × 2) .agents/skills/implementation-final-review/scripts/review_protocol.py:905 — .agents/skills/implementation-final-review/scripts/review_protocol.py:905-913 | .agents/skills/implementation-final-review/scripts/review_protocol.py:918-926 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `.agents/skills/implementation-final-review/scripts/review_protocol.py:905` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 2) src/agents/extensions/memory/async_sqlite_session.py:372 — src/agents/extensions/memory/async_sqlite_session.py:372-380 | src/agents/memory/sqlite_session.py:389-397 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Note first that the copies are not typed on the same thing: `TResponseInputItem` names `...items` in one and `..items` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (9 lines × 2) src/agents/memory/openai_responses_compaction_session.py:940 — src/agents/memory/openai_responses_compaction_session.py:940-948 | src/agents/memory/openai_responses_compaction_session.py:963-971 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/agents/memory/openai_responses_compaction_session.py:960` calls `isinstance` and `src/agents/memory/openai_responses_compaction_session.py:938` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (9 lines × 2) src/agents/models/openai_chatcompletions.py:738 — src/agents/models/openai_chatcompletions.py:738-748 | src/agents/models/openai_responses.py:1063-1071 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/models/openai_chatcompletions.py:738` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (9 lines × 2) src/agents/realtime/session.py:1576 — src/agents/realtime/session.py:1576-1585 | src/agents/realtime/session.py:1636-1644 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) src/agents/run.py:635 — src/agents/run.py:635-643 | src/agents/run.py:2638-2646 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) src/agents/run_internal/items.py:629 — src/agents/run_internal/items.py:629-637 | src/agents/run_internal/items.py:693-701 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (9 lines × 2) src/agents/run_state.py:3867 — src/agents/run_state.py:3867-3875 | src/agents/run_state.py:4004-4012 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `expected_type` to `Literal["input", "output"]` in one and `Literal["tool_input", "tool_output"]` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (9 lines × 2) src/agents/extensions/models/any_llm_model.py:1480 — src/agents/extensions/models/any_llm_model.py:1480-1488 | src/agents/extensions/models/litellm_model.py:379-387 — before extracting anything, compare `src/agents/extensions/models/any_llm_model.py` and `src/agents/extensions/models/litellm_model.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 2) src/agents/extensions/experimental/hosted_multi_agent/model.py:468 — src/agents/extensions/experimental/hosted_multi_agent/model.py:468-476 | src/agents/models/openai_responses.py:1265-1273 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (9 lines × 2) integration_tests/_contract_support.py:62 — integration_tests/_contract_support.py:62-70 | integration_tests/_contract_support.py:156-164 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (16 lines × 2) · ×9
  • Duplicated block (16 lines × 2) src/agents/models/openai_chatcompletions.py:229 — src/agents/models/openai_chatcompletions.py:229-244 | src/agents/models/openai_chatcompletions.py:443-458 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/models/openai_chatcompletions.py:229` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) src/agents/models/openai_provider.py:146 — src/agents/models/openai_provider.py:146-161 | src/agents/voice/models/openai_model_provider.py:89-104 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/models/openai_provider.py:146` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) src/agents/models/openai_responses.py:603 — src/agents/models/openai_responses.py:603-618 | src/agents/models/openai_responses.py:699-714 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/models/openai_responses.py:603` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) src/agents/run.py:1486 — src/agents/run.py:1486-1507 | src/agents/run.py:2212-2227 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run.py:1486` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/agents/run.py:1509` calls `take_held_session_write` and `src/agents/run.py:2228` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) src/agents/run_internal/run_loop.py:1386 — src/agents/run_internal/run_loop.py:1386-1401 | src/agents/run_internal/run_loop.py:1911-1926 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (16 lines × 2) src/agents/run_internal/run_loop.py:2495 — src/agents/run_internal/run_loop.py:2495-2510 | src/agents/run_internal/run_loop.py:2858-2873 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/run_loop.py:2495` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/agents/run_internal/run_loop.py:2490` calls `get_output_schema` and `src/agents/run_internal/run_loop.py:2856` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (16 lines × 2) src/agents/run_internal/tool_actions.py:522 — src/agents/run_internal/tool_actions.py:522-537 | src/agents/run_internal/tool_actions.py:971-986 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/tool_actions.py:522` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (16 lines × 2) examples/sandbox/extensions/blaxel_runner.py:166 — examples/sandbox/extensions/blaxel_runner.py:166-181 | examples/sandbox/extensions/blaxel_runner.py:288-303 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `examples/sandbox/extensions/blaxel_runner.py:166` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (16 lines × 2) integration_tests/_contract_surface.py:306 — integration_tests/_contract_surface.py:306-321 | integration_tests/_contract_surface.py:358-373 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `integration_tests/_contract_surface.py:306` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11 lines × 2) · ×9
  • Duplicated block (11 lines × 2) src/agents/handoffs/history.py:297 — src/agents/handoffs/history.py:297-307 | src/agents/run_state.py:1589-1599 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (11 lines × 2) src/agents/run_internal/items.py:656 — src/agents/run_internal/items.py:656-666 | src/agents/run_internal/items.py:702-712 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) examples/realtime/app/server.py:239 — examples/realtime/app/server.py:239-249 | examples/realtime/app/server.py:428-438 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) src/agents/extensions/sandbox/blaxel/mounts.py:380 — src/agents/extensions/sandbox/blaxel/mounts.py:380-390 | src/agents/extensions/sandbox/blaxel/mounts.py:420-430 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) src/agents/extensions/sandbox/blaxel/sandbox.py:852 — src/agents/extensions/sandbox/blaxel/sandbox.py:852-862 | src/agents/extensions/sandbox/daytona/sandbox.py:714-724 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/sandbox/blaxel/sandbox.py:852` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (11 lines × 2) src/agents/sandbox/capabilities/tools/shell_tool.py:192 — src/agents/sandbox/capabilities/tools/shell_tool.py:192-202 | src/agents/sandbox/capabilities/tools/view_image.py:101-111 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (11 lines × 2) src/agents/sandbox/sandboxes/unix_local.py:1313 — src/agents/sandbox/sandboxes/unix_local.py:1313-1323 | src/agents/sandbox/sandboxes/unix_local.py:1348-1358 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) src/agents/sandbox/session/archive_extraction.py:120 — src/agents/sandbox/session/archive_extraction.py:120-130 | src/agents/sandbox/session/archive_extraction.py:186-196 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (11 lines × 2) src/agents/sandbox/_mount_security.py:660 — src/agents/sandbox/_mount_security.py:660-670 | src/agents/sandbox/entries/mounts/_redaction.py:13-23 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (20 lines × 2) · ×8
  • Duplicated block (20 lines × 2) src/agents/realtime/openai_realtime.py:1758 — src/agents/realtime/openai_realtime.py:1758-1777 | src/agents/realtime/openai_realtime.py:1802-1821 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/realtime/openai_realtime.py:1758` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) src/agents/realtime/session.py:1007 — src/agents/realtime/session.py:1007-1026 | src/agents/realtime/session.py:1059-1078 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (20 lines × 2) src/agents/run.py:1310 — src/agents/run.py:1310-1329 | src/agents/run.py:2366-2385 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run.py:1310` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (20 lines × 2) src/agents/run_internal/model_retry.py:662 — src/agents/run_internal/model_retry.py:662-681 | src/agents/run_internal/model_retry.py:875-894 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/model_retry.py:662` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (20 lines × 2) examples/financial_research_agent/manager.py:149 — examples/financial_research_agent/manager.py:149-168 | examples/research_bot/manager.py:73-92 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/research_bot/manager.py:71` calls `create_task`, `_search` and `examples/financial_research_agent/manager.py:148` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (20 lines × 2) examples/tools/shell.py:121 — examples/tools/shell.py:121-141 | examples/tools/shell_human_in_the_loop.py:31-50 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (20 lines × 2) src/agents/extensions/sandbox/cloudflare/sandbox.py:900 — src/agents/extensions/sandbox/cloudflare/sandbox.py:900-919 | src/agents/extensions/sandbox/cloudflare/sandbox.py:922-941 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (20 lines × 2) examples/memory/memory_session_hitl_example.py:27 — examples/memory/memory_session_hitl_example.py:27-46 | examples/memory/openai_session_hitl_example.py:27-46 — before extracting anything, compare `examples/memory/memory_session_hitl_example.py` and `examples/memory/openai_session_hitl_example.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (17 lines × 2) · ×8
  • Duplicated block (17 lines × 2) src/agents/extensions/models/any_llm_model.py:396 — src/agents/extensions/models/any_llm_model.py:396-412 | src/agents/extensions/models/any_llm_model.py:478-494 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/models/any_llm_model.py:396` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (17 lines × 2) src/agents/memory/session.py:37 — src/agents/memory/session.py:37-53 | src/agents/sandbox/util/blocking_io.py:24-40 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (17 lines × 2) src/agents/run_internal/turn_resolution.py:3338 — src/agents/run_internal/turn_resolution.py:3338-3354 | src/agents/run_internal/turn_resolution.py:3424-3440 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/turn_resolution.py:3424` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (17 lines × 2) examples/agent_patterns/human_in_the_loop.py:119 — examples/agent_patterns/human_in_the_loop.py:119-135 | examples/agent_patterns/human_in_the_loop_stream.py:94-110 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (17 lines × 2) examples/memory/dapr_session_example.py:217 — examples/memory/dapr_session_example.py:217-233 | examples/memory/redis_session_example.py:109-125 — before extracting anything, compare `examples/memory/dapr_session_example.py` and `examples/memory/redis_session_example.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (17 lines × 2) src/agents/extensions/sandbox/blaxel/sandbox.py:1016 — src/agents/extensions/sandbox/blaxel/sandbox.py:1016-1032 | src/agents/extensions/sandbox/daytona/sandbox.py:868-884 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (17 lines × 2) src/agents/extensions/sandbox/daytona/sandbox.py:1123 — src/agents/extensions/sandbox/daytona/sandbox.py:1123-1139 | src/agents/extensions/sandbox/e2b/sandbox.py:1527-1543 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/sandbox/daytona/sandbox.py:1123` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (17 lines × 2) src/agents/extensions/sandbox/daytona/sandbox.py:1141 — src/agents/extensions/sandbox/daytona/sandbox.py:1141-1157 | src/agents/extensions/sandbox/e2b/sandbox.py:1544-1560 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/sandbox/daytona/sandbox.py:1141` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/agents/extensions/sandbox/e2b/sandbox.py:1564` calls `posix_path_for_error` and `src/agents/extensions/sandbox/daytona/sandbox.py:1161` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (13 lines × 2) · ×8
  • Duplicated block (13 lines × 2) src/agents/extensions/models/any_llm_model.py:592 — src/agents/extensions/models/any_llm_model.py:592-604 | src/agents/extensions/models/any_llm_model.py:729-741 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/models/any_llm_model.py:592` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (13 lines × 2) src/agents/run.py:1132 — src/agents/run.py:1132-1144 | src/agents/run_internal/run_loop.py:1431-1443 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (13 lines × 2) src/agents/run_internal/items.py:946 — src/agents/run_internal/items.py:946-958 | src/agents/run_internal/items.py:978-990 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/agents/run_internal/items.py:959` calls `isinstance` and `src/agents/run_internal/items.py:991` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (13 lines × 2) src/agents/run_internal/oai_conversation.py:229 — src/agents/run_internal/oai_conversation.py:229-241 | src/agents/run_internal/oai_conversation.py:356-368 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (13 lines × 2) src/agents/extensions/models/any_llm_model.py:1321 — src/agents/extensions/models/any_llm_model.py:1321-1333 | src/agents/extensions/models/litellm_model.py:893-905 — before extracting anything, compare `src/agents/extensions/models/any_llm_model.py` and `src/agents/extensions/models/litellm_model.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
  • Duplicated block (13 lines × 2) src/agents/models/openai_chatcompletions.py:151 — src/agents/models/openai_chatcompletions.py:151-163 | src/agents/models/openai_responses.py:559-571 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (13 lines × 2) examples/memory/hitl_session_scenario.py:200 — examples/memory/hitl_session_scenario.py:200-212 | examples/memory/hitl_session_scenario.py:262-274 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (13 lines × 2) src/agents/sandbox/entries/mounts/providers/box.py:82 — src/agents/sandbox/entries/mounts/providers/box.py:82-94 | src/agents/sandbox/entries/mounts/providers/r2.py:69-81 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/sandbox/entries/mounts/providers/box.py:82` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
X3 · Exception handling · Swallowed exception (empty catch) · ×8
  • Swallowed exception (empty catch) src/agents/exceptions.py:210 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) src/agents/exceptions.py:224 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) src/agents/exceptions.py:287 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) src/agents/tool.py:2243 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) src/agents/util/_json.py:60 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) src/agents/testing/model.py:584 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) src/agents/run_internal/blocked_output.py:225 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
  • Swallowed exception (empty catch) src/agents/run_internal/error_handlers.py:109 — An empty catch block silently discards the error — failures vanish with no log and no rethrow. Log it, handle it, or don't catch it.
D4 · Code Duplication · Duplicated block (10 lines × 2) · ×7
  • Duplicated block (10 lines × 2) src/agents/realtime/openai_realtime.py:509 — src/agents/realtime/openai_realtime.py:509-518 | src/agents/realtime/session.py:2131-2141 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/realtime/openai_realtime.py:509` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) src/agents/run_state.py:509 — src/agents/run_state.py:509-518 | src/agents/run_state.py:574-583 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_state.py:509` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10 lines × 2) examples/sandbox/docs/coding_task.py:84 — examples/sandbox/docs/coding_task.py:84-93 | examples/sandbox/shared_session_workdirs.py:163-172 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (10 lines × 2) integration_tests/_contract_state.py:192 — integration_tests/_contract_state.py:192-201 | integration_tests/_contract_state.py:342-351 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `integration_tests/_contract_state.py:192` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `integration_tests/_contract_state.py:191` calls `get` and `integration_tests/_contract_state.py:341` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (10 lines × 2) src/agents/extensions/sandbox/e2b/sandbox.py:99 — src/agents/extensions/sandbox/e2b/sandbox.py:99-108 | src/agents/extensions/sandbox/modal/sandbox.py:189-198 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (10 lines × 2) src/agents/sandbox/entries/mounts/providers/s3.py:48 — src/agents/sandbox/entries/mounts/providers/s3.py:48-57 | src/agents/sandbox/entries/mounts/providers/s3.py:61-70 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (10 lines × 2) examples/mcp/sse_example/main.py:59 — examples/mcp/sse_example/main.py:59-68 | examples/mcp/streamablehttp_example/main.py:59-68 — `examples/mcp/sse_example/main.py` and `examples/mcp/streamablehttp_example/main.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 39 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
D4 · Code Duplication · Duplicated block (8 lines × 2) · ×7
  • Duplicated block (8 lines × 2) src/agents/handoffs/history.py:287 — src/agents/handoffs/history.py:287-294 | src/agents/run_internal/session_persistence.py:345-352 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (8 lines × 2) examples/financial_research_agent/printer.py:39 — examples/financial_research_agent/printer.py:39-46 | examples/research_bot/printer.py:34-41 — `examples/financial_research_agent/printer.py` and `examples/research_bot/printer.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 1 separate duplicated blocks between them, totalling at least 8 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (8 lines × 2) src/agents/extensions/sandbox/daytona/sandbox.py:1081 — src/agents/extensions/sandbox/daytona/sandbox.py:1081-1088 | src/agents/extensions/sandbox/e2b/sandbox.py:1488-1495 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (8 lines × 2) src/agents/sandbox/entries/mounts/base.py:248 — src/agents/sandbox/entries/mounts/base.py:248-255 | src/agents/sandbox/entries/mounts/base.py:465-472 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/sandbox/entries/mounts/base.py:248` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (8 lines × 2) examples/sandbox/docs/coding_task.py:72 — examples/sandbox/docs/coding_task.py:72-80 | examples/sandbox/healthcare_support/workflow.py:215-222 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) examples/tools/container_shell_inline_skill.py:43 — examples/tools/container_shell_inline_skill.py:43-50 | examples/tools/container_shell_skill_reference.py:33-40 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (8 lines × 2) src/agents/sandbox/session/base_sandbox_session.py:586 — src/agents/sandbox/session/base_sandbox_session.py:586-593 | src/agents/sandbox/session/snapshot_lifecycle.py:198-205 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (6 lines × 2) · ×7
  • Duplicated block (6 lines × 2) src/agents/run_internal/items.py:622 — src/agents/run_internal/items.py:622-627 | src/agents/run_internal/items.py:685-690 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (6 lines × 2) src/agents/run_internal/turn_resolution.py:3183 — src/agents/run_internal/turn_resolution.py:3183-3188 | src/agents/run_internal/turn_resolution.py:3926-3931 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) src/agents/realtime/testing.py:229 — src/agents/realtime/testing.py:229-234 | src/agents/testing/model.py:314-319 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) .agents/skills/implementation-final-review/scripts/review_protocol.py:687 — .agents/skills/implementation-final-review/scripts/review_protocol.py:687-692 | .agents/skills/implementation-final-review/scripts/review_protocol.py:802-807 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) examples/sandbox/extensions/temporal/temporal_sandbox_tui.py:450 — examples/sandbox/extensions/temporal/temporal_sandbox_tui.py:450-455 | examples/sandbox/extensions/temporal/temporal_sandbox_tui.py:1169-1174 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (6 lines × 2) src/agents/sandbox/capabilities/memory.py:92 — src/agents/sandbox/capabilities/memory.py:92-97 | src/agents/sandbox/memory/rollouts.py:53-58 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (6 lines × 2) src/agents/extensions/sandbox/blaxel/sandbox.py:939 — src/agents/extensions/sandbox/blaxel/sandbox.py:939-944 | src/agents/extensions/sandbox/daytona/sandbox.py:887-892 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (19 lines × 2) · ×6
  • Duplicated block (19 lines × 2) src/agents/extensions/models/litellm_model.py:236 — src/agents/extensions/models/litellm_model.py:236-254 | src/agents/models/openai_chatcompletions.py:240-258 — before extracting anything, compare `src/agents/extensions/models/litellm_model.py` and `src/agents/models/openai_chatcompletions.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 95 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/models/litellm_model.py:236` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) src/agents/extensions/models/litellm_model.py:410 — src/agents/extensions/models/litellm_model.py:410-428 | src/agents/models/openai_chatcompletions.py:454-472 — before extracting anything, compare `src/agents/extensions/models/litellm_model.py` and `src/agents/models/openai_chatcompletions.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 95 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/models/litellm_model.py:410` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (19 lines × 2) src/agents/extensions/models/litellm_model.py:543 — src/agents/extensions/models/litellm_model.py:543-561 | src/agents/models/openai_chatcompletions.py:627-645 — before extracting anything, compare `src/agents/extensions/models/litellm_model.py` and `src/agents/models/openai_chatcompletions.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 95 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/models/litellm_model.py:543` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: `Converter` names `...models.chatcmpl_converter` in one and `.chatcmpl_converter` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (19 lines × 2) integration_tests/_contract_surface.py:194 — integration_tests/_contract_surface.py:194-212 | integration_tests/_contract_surface.py:382-400 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (19 lines × 2) src/agents/extensions/sandbox/blaxel/sandbox.py:179 — src/agents/extensions/sandbox/blaxel/sandbox.py:179-197 | src/agents/extensions/sandbox/modal/sandbox.py:222-240 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (19 lines × 2) examples/basic/remote_image.py:9 — examples/basic/remote_image.py:9-27 | examples/basic/remote_pdf.py:9-27 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
D4 · Code Duplication · Duplicated block (15 lines × 2) · ×6
  • Duplicated block (15 lines × 2) src/agents/agent.py:956 — src/agents/agent.py:956-970 | src/agents/agent.py:1069-1083 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/agent.py:956` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) src/agents/extensions/memory/dapr_session.py:383 — src/agents/extensions/memory/dapr_session.py:383-397 | src/agents/extensions/memory/dapr_session.py:472-486 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (15 lines × 2) src/agents/run_internal/tool_actions.py:545 — src/agents/run_internal/tool_actions.py:545-559 | src/agents/run_internal/tool_actions.py:995-1009 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/tool_actions.py:545` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/agents/run_internal/tool_actions.py:560` calls `ShellCommandRequest` and `src/agents/run_internal/tool_actions.py:1011` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 2) examples/sandbox/extensions/modal_runner.py:177 — examples/sandbox/extensions/modal_runner.py:177-191 | REDACTED:146-160 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `examples/sandbox/extensions/modal_runner.py:177` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) src/agents/extensions/sandbox/e2b/sandbox.py:647 — src/agents/extensions/sandbox/e2b/sandbox.py:647-661 | src/agents/extensions/sandbox/modal/sandbox.py:321-335 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/sandbox/e2b/sandbox.py:647` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 2) src/agents/extensions/sandbox/daytona/sandbox.py:348 — src/agents/extensions/sandbox/daytona/sandbox.py:348-362 | src/agents/extensions/sandbox/vercel/sandbox.py:441-455 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (7 lines × 2) · ×5
  • Duplicated block (7 lines × 2) .agents/skills/release-candidate-prep/scripts/prepare.py:604 — .agents/skills/release-candidate-prep/scripts/prepare.py:604-610 | .agents/skills/release-candidate-prep/scripts/prepare.py:613-619 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (7 lines × 2) src/agents/models/_retry_runtime.py:17 — src/agents/models/_retry_runtime.py:17-23 | src/agents/models/openai_responses.py:434-440 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once.
  • Duplicated block (7 lines × 2) src/agents/models/openai_chatcompletions.py:785 — src/agents/models/openai_chatcompletions.py:785-791 | src/agents/models/openai_responses.py:1125-1131 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7 lines × 2) examples/mcp/sse_example/main.py:17 — examples/mcp/sse_example/main.py:17-23 | examples/mcp/sse_remote_example/main.py:21-27 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/mcp/sse_remote_example/main.py:17` calls `getenv` and `examples/mcp/sse_example/main.py:13` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (7 lines × 2) src/agents/extensions/sandbox/modal/mounts.py:122 — src/agents/extensions/sandbox/modal/mounts.py:122-128 | src/agents/sandbox/entries/mounts/providers/s3.py:43-53 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D3 · God Classes · TooManyMethods · ×4
  • TooManyMethods: OpenAIRealtimeWebSocketModel src/agents/realtime/openai_realtime.py:555 — TooManyMethods — 52 methods. The bar is 30 methods; this is 22 over it, 1.73× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: RealtimeSession src/agents/realtime/session.py:177 — TooManyMethods — 52 methods. The bar is 30 methods; this is 22 over it, 1.73× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: AnyLLMModel src/agents/extensions/models/any_llm_model.py:254 — TooManyMethods — 44 methods. The bar is 30 methods; this is 14 over it, 1.47× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
  • TooManyMethods: AdvancedSQLiteSession src/agents/extensions/memory/advanced_sqlite_session.py:59 — TooManyMethods — 43 methods. The bar is 30 methods; this is 13 over it, 1.43× the bar. To reduce it, group the members that share the same data into a smaller type of their own and delegate to it, so no single type carries every responsibility.
D4 · Code Duplication · Duplicated block (14 lines × 2) · ×4
  • Duplicated block (14 lines × 2) src/agents/extensions/models/any_llm_model.py:944 — src/agents/extensions/models/any_llm_model.py:944-957 | src/agents/extensions/models/litellm_model.py:639-652 — before extracting anything, compare `src/agents/extensions/models/any_llm_model.py` and `src/agents/extensions/models/litellm_model.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/agents/extensions/models/litellm_model.py:653` calls `_merge_headers` and `src/agents/extensions/models/any_llm_model.py:958` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) src/agents/realtime/openai_realtime.py:514 — src/agents/realtime/openai_realtime.py:514-527 | src/agents/realtime/openai_realtime.py:1951-1964 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (14 lines × 2) src/agents/run_internal/run_loop.py:2475 — src/agents/run_internal/run_loop.py:2475-2488 | src/agents/run_internal/run_loop.py:2843-2856 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/run_loop.py:2475` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/agents/run_internal/run_loop.py:2490` calls `get_output_schema` and `src/agents/run_internal/run_loop.py:2858` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (14 lines × 2) examples/sandbox/extensions/modal_runner.py:204 — examples/sandbox/extensions/modal_runner.py:204-217 | REDACTED:162-175 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `examples/sandbox/extensions/modal_runner.py:204` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (12 lines × 2) · ×4
  • Duplicated block (12 lines × 2) src/agents/run.py:2498 — src/agents/run.py:2498-2509 | src/agents/run_internal/run_loop.py:2403-2414 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
  • Duplicated block (12 lines × 2) src/agents/run_internal/error_handlers.py:148 — src/agents/run_internal/error_handlers.py:148-159 | src/agents/run_internal/error_handlers.py:179-190 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (12 lines × 2) src/agents/run_internal/model_retry.py:647 — src/agents/run_internal/model_retry.py:647-658 | src/agents/run_internal/model_retry.py:860-871 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/model_retry.py:647` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (12 lines × 2) examples/model_providers/any_llm_provider.py:32 — examples/model_providers/any_llm_provider.py:32-44 | examples/model_providers/litellm_provider.py:33-44 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (5 lines × 2) · ×4
  • Duplicated block (5 lines × 2) src/agents/extensions/experimental/codex/events.py:92 — src/agents/extensions/experimental/codex/events.py:92-96 | src/agents/extensions/experimental/codex/items.py:164-168 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `raw` to `ThreadError | Mapping[str, Any]` in one and `McpToolCallError | Mapping[str, Any]` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (5 lines × 2) integration_tests/_contract_surface.py:85 — integration_tests/_contract_surface.py:85-89 | integration_tests/_contract_surface.py:108-115 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `integration_tests/_contract_surface.py:108` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
  • Duplicated block (5 lines × 2) src/agents/sandbox/entries/artifacts.py:68 — src/agents/sandbox/entries/artifacts.py:68-72 | src/agents/sandbox/manifest.py:284-288 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 2) REDACTED:597 — REDACTED:597-601 | REDACTED:690-694 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (5 lines × 3) · ×4
  • Duplicated block (5 lines × 3) examples/sandbox/extensions/blaxel_runner.py:126 — examples/sandbox/extensions/blaxel_runner.py:126-130 | examples/sandbox/extensions/cloudflare_runner.py:209-213 | examples/sandbox/unix_local_pty.py:80-84 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
  • Duplicated block (5 lines × 3) examples/sandbox/extensions/cloudflare_runner.py:140 — examples/sandbox/extensions/cloudflare_runner.py:140-144 | examples/sandbox/extensions/modal_runner.py:153-157 | REDACTED:109-113 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (5 lines × 3) src/agents/extensions/sandbox/blaxel/mounts.py:162 — src/agents/extensions/sandbox/blaxel/mounts.py:162-166 | src/agents/extensions/sandbox/daytona/mounts.py:156-160 | src/agents/extensions/sandbox/e2b/mounts.py:60-64 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
  • Duplicated block (5 lines × 3) src/agents/sandbox/capabilities/skills.py:549 — src/agents/sandbox/capabilities/skills.py:549-553 | src/agents/sandbox/entries/artifacts.py:60-64 | src/agents/sandbox/manifest.py:276-280 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
X17 · Uncapped recursion over a caller-supplied document · Recursive walk over a caller-supplied document has no depth cap · ×4
  • Recursive walk over a caller-supplied document has no depth cap src/agents/_function_tool_arguments.py:164 — `arguments_unchanged` is public, takes a document from its caller (line 111) and hands it to `_same_json`, which calls itself at line 164 (`_same_json`) with a piece of `left` (and at line 167) — and nowhere in `_same_json` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_same_json` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap src/agents/run_state.py:2559 — `from_json` is public, takes a document from its caller (line 2433) and hands it to `_validate_run_state_json_value`, which calls itself at line 2559 (`_validate_run_state_json_value`) with a piece of `value` (and at line 2563) — and nowhere in `_validate_run_state_json_value` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_validate_run_state_json_value` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap src/agents/strict_schema.py:519 — `ensure_strict_json_schema` is public, takes a document from its caller (line 116) and hands it to `_json_values_equal`, which calls itself at line 519 (`_json_values_equal`) with a piece of `left` (and at line 526) — and nowhere in `_json_values_equal` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_json_values_equal` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
  • Recursive walk over a caller-supplied document has no depth cap src/agents/models/openai_agent_registration.py:103 — `resolve_openai_harness_id_for_model_provider` is public, takes a document from its caller (line 65) and hands it to `_harness_id_from_model_provider`, which calls itself at line 103 (`_harness_id_from_model_provider`) with a piece of `model_provider` — and nowhere in `_harness_id_from_model_provider` is there a depth parameter, a descent counter, or any other cap. The walk therefore spends one stack frame per LEVEL of the value it is handed, so the nesting of the caller's document — not this code — decides how deep the stack goes. Python's parsers accept far more nesting than its stack allows: `json.loads` turns 3,000 bytes of brackets into 1,500 levels and `xml.etree.ElementTree` parses tens of thousands, while a walk like this one raises `RecursionError` once it passes the interpreter's default limit of 1,000 frames. Wherever that exception lands, the work fails: a request errors, and outside any `try` the worker or the program exits with it. Raising `sys.setrecursionlimit` only moves the number the document has to beat. Thread a depth argument through `_harness_id_from_model_provider` and reject the value past a fixed maximum, or rewrite the descent with an explicit stack.
D4 · Code Duplication · Members sharing a duplicated core (4 members, 50+ identical tokens) · ×3
  • Members sharing a duplicated core (4 members, 50+ identical tokens) src/agents/mcp/server.py:1989 — src/agents/mcp/server.py:1989-2070 | src/agents/mcp/server.py:2139-2214 | src/agents/mcp/server.py:2317-2394 | src/agents/run.py:2638-2932 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) integration_tests/_contract_validation.py:89 — integration_tests/_contract_validation.py:89-139 | integration_tests/_contract_validation.py:148-186 | integration_tests/_contract_validation.py:195-227 | integration_tests/_contract_validation.py:236-274 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
  • Members sharing a duplicated core (4 members, 50+ identical tokens) src/agents/extensions/sandbox/cloudflare/sandbox.py:1074 — src/agents/extensions/sandbox/cloudflare/sandbox.py:1074-1086 | src/agents/extensions/sandbox/e2b/sandbox.py:1294-1306 | src/agents/sandbox/sandboxes/docker.py:1370-1382 | src/agents/sandbox/sandboxes/unix_local.py:692-704 — These 4 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 4 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 4 times.
D4 · Code Duplication · Duplicated block (22 lines × 2) · ×3
  • Duplicated block (22 lines × 2) src/agents/extensions/models/any_llm_model.py:688 — src/agents/extensions/models/any_llm_model.py:688-709 | src/agents/models/openai_chatcompletions.py:360-381 — before extracting anything, compare `src/agents/extensions/models/any_llm_model.py` and `src/agents/models/openai_chatcompletions.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 117 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/models/any_llm_model.py:688` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (22 lines × 2) src/agents/extensions/models/litellm_model.py:569 — src/agents/extensions/models/litellm_model.py:569-590 | src/agents/models/openai_responses.py:995-1016 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/models/litellm_model.py:569` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (22 lines × 2) examples/sandbox/extensions/cloudflare_runner.py:163 — examples/sandbox/extensions/cloudflare_runner.py:163-184 | REDACTED:151-172 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `examples/sandbox/extensions/cloudflare_runner.py:163` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18 lines × 2) · ×3
  • Duplicated block (18 lines × 2) src/agents/extensions/visualization.py:251 — src/agents/extensions/visualization.py:251-268 | src/agents/extensions/visualization.py:274-291 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/visualization.py:251` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (18 lines × 2) src/agents/mcp/manager.py:481 — src/agents/mcp/manager.py:481-498 | src/agents/mcp/manager.py:585-602 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (18 lines × 2) src/agents/run_internal/guardrails.py:140 — src/agents/run_internal/guardrails.py:140-157 | src/agents/run_internal/guardrails.py:196-213 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Note first that the copies are not typed on the same thing: the declarations holding them bind `result` to `InputGuardrailResult` in one and `OutputGuardrailResult` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (12 lines × 3) · ×3
  • Duplicated block (12 lines × 3) src/agents/run_internal/run_loop.py:2501 — src/agents/run_internal/run_loop.py:2501-2512 | src/agents/run_internal/run_loop.py:2864-2875 | src/agents/run_internal/turn_resolution.py:2280-2291 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (12 lines × 3) examples/mcp/sse_example/main.py:32 — examples/mcp/sse_example/main.py:32-43 | examples/mcp/streamablehttp_custom_client_example/main.py:73-84 | examples/mcp/streamablehttp_example/main.py:32-43 — `examples/mcp/sse_example/main.py` and `examples/mcp/streamablehttp_example/main.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 39 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own.
  • Duplicated block (12 lines × 3) src/agents/extensions/sandbox/cloudflare/sandbox.py:1074 — src/agents/extensions/sandbox/cloudflare/sandbox.py:1074-1085 | src/agents/sandbox/sandboxes/docker.py:1370-1381 | src/agents/sandbox/sandboxes/unix_local.py:692-703 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (9 lines × 3) · ×3
  • Duplicated block (9 lines × 3) src/agents/mcp/server.py:1574 — src/agents/mcp/server.py:1574-1582 | src/agents/mcp/server.py:1630-1638 | src/agents/mcp/server.py:2606-2614 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/mcp/server.py:1574` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (9 lines × 3) examples/memory/file_hitl_example.py:90 — examples/memory/file_hitl_example.py:90-98 | examples/memory/memory_session_hitl_example.py:80-90 | examples/memory/openai_session_hitl_example.py:78-88 — before extracting anything, compare `examples/memory/memory_session_hitl_example.py` and `examples/memory/openai_session_hitl_example.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (9 lines × 3) src/agents/extensions/sandbox/blaxel/sandbox.py:160 — src/agents/extensions/sandbox/blaxel/sandbox.py:160-168 | src/agents/extensions/sandbox/daytona/sandbox.py:101-109 | src/agents/extensions/sandbox/modal/sandbox.py:123-131 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D2 · Cognitive Complexity · _asyncio_tasks.gather_with_cancel (cognitive 32) · ×2
  • _asyncio_tasks.gather_with_cancel (cognitive 32) src/agents/util/_asyncio_tasks.py:97 — _asyncio_tasks.gather_with_cancel has cognitive complexity 32 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 3 (9 pts), error handling 4 (6 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (_asyncio_tasks.gather_with_cancel) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
  • _asyncio_tasks.gather_with_cancel (cognitive 32) src/agents/util/_asyncio_tasks.py:105 — _asyncio_tasks.gather_with_cancel has cognitive complexity 32 (threshold 15). Drivers by points: if/else 6 (16 pts), loops 3 (9 pts), error handling 4 (6 pts), boolean chains 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body. This shape REPEATS in the file: one other method here (_asyncio_tasks.gather_with_cancel) has the same decision points, in the same order, at the same nesting depths — so this is one pattern written twice rather than two separate problems. Splitting this body alone leaves the other exactly as it is. Where these are variations on one operation, the change that clears both is the shared one: lift the common shape into a single routine the variants call, parameterised by whatever genuinely differs between them, and keep in each method only the part that is not shared.
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
D4 · Code Duplication · Duplicated block (26 lines × 2) · ×2
  • Duplicated block (26 lines × 2) src/agents/mcp/server.py:1626 — src/agents/mcp/server.py:1626-1651 | src/agents/mcp/server.py:2602-2627 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (26 lines × 2) src/agents/extensions/sandbox/blaxel/sandbox.py:743 — src/agents/extensions/sandbox/blaxel/sandbox.py:743-768 | src/agents/extensions/sandbox/daytona/sandbox.py:1160-1185 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (17 lines × 3) · ×2
  • Duplicated block (17 lines × 3) src/agents/extensions/memory/advanced_sqlite_session.py:427 — src/agents/extensions/memory/advanced_sqlite_session.py:427-443 | src/agents/extensions/memory/async_sqlite_session.py:249-266 | src/agents/memory/sqlite_session.py:287-303 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Note first that the copies are not typed on the same thing: `TResponseInputItem` names `...items` in one and `..items` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
  • Duplicated block (17 lines × 3) examples/mcp/filesystem_example/main.py:14 — examples/mcp/filesystem_example/main.py:14-30 | examples/mcp/sse_example/main.py:37-53 | examples/mcp/streamablehttp_example/main.py:37-53 — `examples/mcp/sse_example/main.py` and `examples/mcp/streamablehttp_example/main.py` are one unit implemented once per sibling directory, so they are most likely parallel implementations of one contract rather than a copy of each other — this scan matched 3 separate duplicated blocks between them, totalling at least 39 lines. If both are selected at run time, neither can be retired in favour of the other, and the lines that DIFFER between them are the reason both exist. The move that pays here is to hoist the identical part into a shared location the whole family can reach and give what differs a parameter or a seam, so a change lands once instead of once per sibling; extracting one helper per block leaves every sibling to drift on its own. Read the line range as the matched WINDOW rather than a finished unit: at `examples/mcp/filesystem_example/main.py:14` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/mcp/sse_example/main.py:36` calls `ModelSettings` and `examples/mcp/filesystem_example/main.py:13` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16–17 lines × 2) · ×2
  • Duplicated block (16–17 lines × 2) src/agents/models/chatcmpl_stream_handler.py:722 — src/agents/models/chatcmpl_stream_handler.py:722-737 | src/agents/models/chatcmpl_stream_handler.py:745-761 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
  • Duplicated block (16–17 lines × 2) src/agents/run_state.py:392 — src/agents/run_state.py:392-407 | src/agents/run_state.py:454-470 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (15 lines × 4) · ×2
  • Duplicated block (15 lines × 4) src/agents/mcp/server.py:2045 — src/agents/mcp/server.py:2045-2059 | src/agents/mcp/server.py:2197-2211 | src/agents/mcp/server.py:2376-2390 | src/agents/run.py:2905-2919 — there are 4 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 4 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/mcp/server.py:2045` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (15 lines × 4) integration_tests/_contract_validation.py:94 — integration_tests/_contract_validation.py:94-108 | integration_tests/_contract_validation.py:153-167 | integration_tests/_contract_validation.py:200-214 | integration_tests/_contract_validation.py:242-256 — all 4 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (15 lines × 3) · ×2
  • Duplicated block (15 lines × 3) src/agents/run_internal/turn_resolution.py:3441 — src/agents/run_internal/turn_resolution.py:3441-3455 | src/agents/run_internal/turn_resolution.py:3725-3739 | src/agents/run_internal/turn_resolution.py:3774-3788 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/agents/run_internal/turn_resolution.py:3456` calls `get_mapping_or_attr`, `debug` and `src/agents/run_internal/turn_resolution.py:3740` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (15 lines × 3) examples/sandbox/extensions/cloudflare_runner.py:167 — examples/sandbox/extensions/cloudflare_runner.py:167-181 | examples/sandbox/extensions/e2b_runner.py:110-124 | REDACTED:155-169 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `examples/sandbox/extensions/cloudflare_runner.py:167` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14 lines × 3) · ×2
  • Duplicated block (14 lines × 3) src/agents/run.py:1735 — src/agents/run.py:1735-1748 | src/agents/run_internal/run_loop.py:1861-1874 | src/agents/run_internal/run_loop.py:1952-1965 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart.
  • Duplicated block (14 lines × 3) examples/memory/advanced_sqlite_session_example.py:50 — examples/memory/advanced_sqlite_session_example.py:50-63 | examples/memory/advanced_sqlite_session_example.py:65-78 | examples/memory/advanced_sqlite_session_example.py:80-93 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (10–11 lines × 2) · ×2
  • Duplicated block (10–11 lines × 2) src/agents/run_internal/turn_resolution.py:1029 — src/agents/run_internal/turn_resolution.py:1029-1039 | src/agents/run_internal/turn_resolution.py:2811-2820 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/turn_resolution.py:1029` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
  • Duplicated block (10–11 lines × 2) src/agents/util/_pretty_print.py:37 — src/agents/util/_pretty_print.py:37-47 | src/agents/util/_pretty_print.py:70-79 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note first that the copies are not typed on the same thing: the declarations holding them bind `result` to `"RunResult"` in one and `"RunResultStreaming"` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Members sharing a duplicated core (6 members, 50+ identical tokens) · ×2
  • Members sharing a duplicated core (6 members, 50+ identical tokens) examples/memory/dapr_session_example.py:117 — examples/memory/dapr_session_example.py:117-240 | examples/memory/encrypted_session_example.py:21-112 | examples/memory/openai_session_example.py:15-74 | examples/memory/redis_session_example.py:22-150 | examples/memory/sqlalchemy_session_example.py:9-72 | examples/memory/sqlite_session_example.py:15-73 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
  • Members sharing a duplicated core (6 members, 50+ identical tokens) src/agents/extensions/sandbox/blaxel/sandbox.py:908 — src/agents/extensions/sandbox/blaxel/sandbox.py:908-936 | src/agents/extensions/sandbox/daytona/sandbox.py:827-857 | src/agents/extensions/sandbox/e2b/sandbox.py:1076-1107 | src/agents/extensions/sandbox/modal/sandbox.py:938-965 | src/agents/sandbox/sandboxes/docker.py:1186-1226 | src/agents/sandbox/sandboxes/unix_local.py:540-576 — These 6 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 6 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 6 times.
D4 · Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) · ×2
  • Members sharing a duplicated core (5 members, 50+ identical tokens) src/agents/extensions/sandbox/blaxel/sandbox.py:560 — src/agents/extensions/sandbox/blaxel/sandbox.py:560-574 | src/agents/extensions/sandbox/cloudflare/sandbox.py:1372-1431 | src/agents/extensions/sandbox/daytona/sandbox.py:997-1015 | src/agents/extensions/sandbox/e2b/sandbox.py:1163-1182 | src/agents/extensions/sandbox/modal/sandbox.py:1315-1357 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
  • Members sharing a duplicated core (5 members, 50+ identical tokens) src/agents/extensions/sandbox/cloudflare/sandbox.py:1056 — src/agents/extensions/sandbox/cloudflare/sandbox.py:1056-1071 | src/agents/extensions/sandbox/e2b/sandbox.py:1275-1291 | src/agents/extensions/sandbox/modal/sandbox.py:1172-1187 | src/agents/sandbox/sandboxes/docker.py:1348-1367 | src/agents/sandbox/sandboxes/unix_local.py:673-689 — These 5 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 5 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 5 times.
D4 · Code Duplication · Duplicated block (21 lines × 2) · ×2
  • Duplicated block (21 lines × 2) integration_tests/_contract_validation.py:148 — integration_tests/_contract_validation.py:148-168 | integration_tests/_contract_validation.py:195-215 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (21 lines × 2) examples/model_providers/any_llm_auto.py:25 — examples/model_providers/any_llm_auto.py:25-45 | examples/model_providers/litellm_auto.py:28-49 — before extracting anything, compare `examples/model_providers/any_llm_auto.py` and `examples/model_providers/litellm_auto.py` as WHOLE FILES: 94% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (18 lines × 3) · ×2
  • Duplicated block (18 lines × 3) examples/sandbox/extensions/daytona/daytona_runner.py:107 — examples/sandbox/extensions/daytona/daytona_runner.py:107-124 | examples/sandbox/extensions/modal_runner.py:272-290 | REDACTED:328-346 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `examples/sandbox/extensions/daytona/daytona_runner.py:107` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/sandbox/extensions/daytona/daytona_runner.py:126` calls `DaytonaSandboxClient` and `examples/sandbox/extensions/modal_runner.py:292` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (18 lines × 3) integration_tests/_contract_validation.py:150 — integration_tests/_contract_validation.py:150-167 | integration_tests/_contract_validation.py:197-214 | integration_tests/_contract_validation.py:239-256 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `integration_tests/_contract_validation.py:238` calls `object` and `integration_tests/_contract_validation.py:149` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (8 lines × 5) · ×2
  • Duplicated block (8 lines × 5) src/agents/extensions/sandbox/blaxel/sandbox.py:561 — src/agents/extensions/sandbox/blaxel/sandbox.py:561-568 | src/agents/extensions/sandbox/cloudflare/sandbox.py:1373-1380 | src/agents/extensions/sandbox/daytona/sandbox.py:998-1005 | src/agents/extensions/sandbox/e2b/sandbox.py:1163-1170 | src/agents/extensions/sandbox/modal/sandbox.py:1315-1322 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/agents/extensions/sandbox/blaxel/sandbox.py:560` calls `posix_path_as_path`, `coerce_posix_path` and `src/agents/extensions/sandbox/e2b/sandbox.py:1162` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
  • Duplicated block (8 lines × 5) src/agents/extensions/sandbox/cloudflare/sandbox.py:1038 — src/agents/extensions/sandbox/cloudflare/sandbox.py:1038-1045 | src/agents/extensions/sandbox/daytona/sandbox.py:901-908 | src/agents/extensions/sandbox/e2b/sandbox.py:1233-1240 | src/agents/sandbox/sandboxes/docker.py:1330-1337 | src/agents/sandbox/sandboxes/unix_local.py:655-662 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: the declarations holding them bind `entry` to `_CloudflarePtyProcessEntry` in one and `_DockerPtyProcessEntry` in another, and the duplicated lines use it. The extracted unit therefore needs a parameter type that fits BOTH — their common supertype where they have one, or a new abstraction over them where they do not — and settling that is the step that comes BEFORE the extraction above. Where the two types are deliberately unrelated, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (7–8 lines × 2) · ×2
  • Duplicated block (7–8 lines × 2) examples/sandbox/healthcare_support/data.py:27 — examples/sandbox/healthcare_support/data.py:27-33 | examples/sandbox/tutorials/misc.py:95-102 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
  • Duplicated block (7–8 lines × 2) src/agents/sandbox/entries/mounts/patterns.py:841 — src/agents/sandbox/entries/mounts/patterns.py:841-847 | src/agents/sandbox/entries/mounts/patterns.py:908-915 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/sandbox/entries/mounts/patterns.py:908` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D1 · Cyclomatic Complexity · AgentRunner._run_impl (cyclomatic 239) · ×1
  • AgentRunner._run_impl (cyclomatic 239) src/agents/run.py:629 — AgentRunner._run_impl has cyclomatic complexity 239 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_loop.start_streaming (cyclomatic 201) · ×1
  • run_loop.start_streaming (cyclomatic 201) src/agents/run_internal/run_loop.py:987 — run_loop.start_streaming has cyclomatic complexity 201 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · turn_resolution.resolve_interrupted_turn (cyclomatic 170) · ×1
  • turn_resolution.resolve_interrupted_turn (cyclomatic 170) src/agents/run_internal/turn_resolution.py:1387 — turn_resolution.resolve_interrupted_turn has cyclomatic complexity 170 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ChatCmplStreamHandler.handle_stream (cyclomatic 129) · ×1
  • ChatCmplStreamHandler.handle_stream (cyclomatic 129) src/agents/models/chatcmpl_stream_handler.py:603 — ChatCmplStreamHandler.handle_stream has cyclomatic complexity 129 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_state._build_run_state_from_json (cyclomatic 115) · ×1
  • run_state._build_run_state_from_json (cyclomatic 115) src/agents/run_state.py:4174 — run_state._build_run_state_from_json has cyclomatic complexity 115 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · review_protocol.validate_packet (cyclomatic 109) · ×1
  • review_protocol.validate_packet (cyclomatic 109) .agents/skills/implementation-final-review/scripts/review_protocol.py:526 — review_protocol.validate_packet has cyclomatic complexity 109 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · turn_resolution.process_model_response (cyclomatic 101) · ×1
  • turn_resolution.process_model_response (cyclomatic 101) src/agents/run_internal/turn_resolution.py:3158 — turn_resolution.process_model_response has cyclomatic complexity 101 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Converter.items_to_messages (cyclomatic 75) · ×1
  • Converter.items_to_messages (cyclomatic 75) src/agents/models/chatcmpl_converter.py:548 — Converter.items_to_messages has cyclomatic complexity 75 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIResponsesCompactionSession._run_compaction_locked (cyclomatic 60) · ×1
  • OpenAIResponsesCompactionSession._run_compaction_locked (cyclomatic 60) src/agents/memory/openai_responses_compaction_session.py:273 — OpenAIResponsesCompactionSession._run_compaction_locked has cyclomatic complexity 60 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunContextWrapper.get_approval_status (cyclomatic 60) · ×1
  • RunContextWrapper.get_approval_status (cyclomatic 60) src/agents/run_context.py:1369 — RunContextWrapper.get_approval_status has cyclomatic complexity 60 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RealtimeSession.on_event (cyclomatic 59) · ×1
  • RealtimeSession.on_event (cyclomatic 59) src/agents/realtime/session.py:412 — RealtimeSession.on_event has cyclomatic complexity 59 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIRealtimeWebSocketModel._handle_ws_event (cyclomatic 58) · ×1
  • OpenAIRealtimeWebSocketModel._handle_ws_event (cyclomatic 58) src/agents/realtime/openai_realtime.py:1370 — OpenAIRealtimeWebSocketModel._handle_ws_event has cyclomatic complexity 58 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIServerConversationTracker.hydrate_from_state (cyclomatic 57) · ×1
  • OpenAIServerConversationTracker.hydrate_from_state (cyclomatic 57) src/agents/run_internal/oai_conversation.py:177 — OpenAIServerConversationTracker.hydrate_from_state has cyclomatic complexity 57 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RealtimeSession._get_new_history (cyclomatic 54) · ×1
  • RealtimeSession._get_new_history (cyclomatic 54) src/agents/realtime/session.py:1506 — RealtimeSession._get_new_history has cyclomatic complexity 54 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_state._validate_completed_tool_invocations (cyclomatic 52) · ×1
  • run_state._validate_completed_tool_invocations (cyclomatic 52) src/agents/run_state.py:4820 — run_state._validate_completed_tool_invocations has cyclomatic complexity 52 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RealtimeSession._handle_tool_call (cyclomatic 51) · ×1
  • RealtimeSession._handle_tool_call (cyclomatic 51) src/agents/realtime/session.py:1096 — RealtimeSession._handle_tool_call has cyclomatic complexity 51 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunContextWrapper._apply_approval_decision (cyclomatic 50) · ×1
  • RunContextWrapper._apply_approval_decision (cyclomatic 50) src/agents/run_context.py:1180 — RunContextWrapper._apply_approval_decision has cyclomatic complexity 50 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · review_protocol.validate_reviewer_output (cyclomatic 48) · ×1
  • review_protocol.validate_reviewer_output (cyclomatic 48) .agents/skills/implementation-final-review/scripts/review_protocol.py:1030 — review_protocol.validate_reviewer_output has cyclomatic complexity 48 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · function_schema.function_schema (cyclomatic 45) · ×1
  • function_schema.function_schema (cyclomatic 45) src/agents/function_schema.py:321 — function_schema.function_schema has cyclomatic complexity 45 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · strict_schema._ensure_strict_json_schema (cyclomatic 44) · ×1
  • strict_schema._ensure_strict_json_schema (cyclomatic 44) src/agents/strict_schema.py:156 — strict_schema._ensure_strict_json_schema has cyclomatic complexity 44 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · session_persistence.resume_pending_session_write (cyclomatic 41) · ×1
  • session_persistence.resume_pending_session_write (cyclomatic 41) src/agents/run_internal/session_persistence.py:1444 — session_persistence.resume_pending_session_write has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_state._copy_pydantic_value (cyclomatic 41) · ×1
  • run_state._copy_pydantic_value (cyclomatic 41) src/agents/run_state.py:446 — run_state._copy_pydantic_value has cyclomatic complexity 41 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · turn_resolution.execute_tools_and_side_effects (cyclomatic 40) · ×1
  • turn_resolution.execute_tools_and_side_effects (cyclomatic 40) src/agents/run_internal/turn_resolution.py:966 — turn_resolution.execute_tools_and_side_effects has cyclomatic complexity 40 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · codex_tool._enforce_span_data_budget (cyclomatic 39) · ×1
  • codex_tool._enforce_span_data_budget (cyclomatic 39) src/agents/extensions/experimental/codex/codex_tool.py:1313 — codex_tool._enforce_span_data_budget has cyclomatic complexity 39 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIHostedMultiAgentModel._iter_websocket_turn (cyclomatic 38) · ×1
  • OpenAIHostedMultiAgentModel._iter_websocket_turn (cyclomatic 38) src/agents/extensions/experimental/hosted_multi_agent/model.py:733 — OpenAIHostedMultiAgentModel._iter_websocket_turn has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · turn_resolution._preflight_response_invocations_after_processing_error (cyclomatic 38) · ×1
  • turn_resolution._preflight_response_invocations_after_processing_error (cyclomatic 38) src/agents/run_internal/turn_resolution.py:3918 — turn_resolution._preflight_response_invocations_after_processing_error has cyclomatic complexity 38 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · items.drop_orphan_function_calls (cyclomatic 36) · ×1
  • items.drop_orphan_function_calls (cyclomatic 36) src/agents/run_internal/items.py:211 — items.drop_orphan_function_calls has cyclomatic complexity 36 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Converter.message_to_output_items (cyclomatic 35) · ×1
  • Converter.message_to_output_items (cyclomatic 35) src/agents/models/chatcmpl_converter.py:123 — Converter.message_to_output_items has cyclomatic complexity 35 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_state._restore_current_response_item_identities (cyclomatic 35) · ×1
  • run_state._restore_current_response_item_identities (cyclomatic 35) src/agents/run_state.py:5458 — run_state._restore_current_response_item_identities has cyclomatic complexity 35 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · MCPUtil.invoke_mcp_tool (cyclomatic 34) · ×1
  • MCPUtil.invoke_mcp_tool (cyclomatic 34) REDACTED:686 — MCPUtil.invoke_mcp_tool has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Converter._convert_tool (cyclomatic 34) · ×1
  • Converter._convert_tool (cyclomatic 34) src/agents/models/openai_responses.py:2252 — Converter._convert_tool has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · turn_resolution.execute_handoffs (cyclomatic 34) · ×1
  • turn_resolution.execute_handoffs (cyclomatic 34) src/agents/run_internal/turn_resolution.py:544 — turn_resolution.execute_handoffs has cyclomatic complexity 34 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIRealtimeWebSocketModel._get_session_config (cyclomatic 33) · ×1
  • OpenAIRealtimeWebSocketModel._get_session_config (cyclomatic 33) src/agents/realtime/openai_realtime.py:1737 — OpenAIRealtimeWebSocketModel._get_session_config has cyclomatic complexity 33 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · AgentRunner.run_streamed (cyclomatic 33) · ×1
  • AgentRunner.run_streamed (cyclomatic 33) src/agents/run.py:2632 — AgentRunner.run_streamed has cyclomatic complexity 33 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · model_retry.stream_response_with_retry (cyclomatic 33) · ×1
  • model_retry.stream_response_with_retry (cyclomatic 33) src/agents/run_internal/model_retry.py:684 — model_retry.stream_response_with_retry has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_loop.run_single_turn_streamed (cyclomatic 33) · ×1
  • run_loop.run_single_turn_streamed (cyclomatic 33) src/agents/run_internal/run_loop.py:2423 — run_loop.run_single_turn_streamed has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · session_persistence.save_result_to_session (cyclomatic 33) · ×1
  • session_persistence.save_result_to_session (cyclomatic 33) src/agents/run_internal/session_persistence.py:778 — session_persistence.save_result_to_session has cyclomatic complexity 33 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · tool_planning._dedupe_processed_response_invocations (cyclomatic 33) · ×1
  • tool_planning._dedupe_processed_response_invocations (cyclomatic 33) src/agents/run_internal/tool_planning.py:347 — tool_planning._dedupe_processed_response_invocations has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_state._deserialize_items (cyclomatic 33) · ×1
  • run_state._deserialize_items (cyclomatic 33) src/agents/run_state.py:5159 — run_state._deserialize_items has cyclomatic complexity 33 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIResponsesWSModel._iter_websocket_response_events (cyclomatic 32) · ×1
  • OpenAIResponsesWSModel._iter_websocket_response_events (cyclomatic 32) src/agents/models/openai_responses.py:1360 — OpenAIResponsesWSModel._iter_websocket_response_events has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIRealtimeWebSocketModel._interrupt_audio_playback (cyclomatic 32) · ×1
  • OpenAIRealtimeWebSocketModel._interrupt_audio_playback (cyclomatic 32) src/agents/realtime/openai_realtime.py:1044 — OpenAIRealtimeWebSocketModel._interrupt_audio_playback has cyclomatic complexity 32 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · model_retry._evaluate_retry (cyclomatic 31) · ×1
  • model_retry._evaluate_retry (cyclomatic 31) src/agents/run_internal/model_retry.py:389 — model_retry._evaluate_retry has cyclomatic complexity 31 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · OpenAIServerConversationTracker.prepare_input (cyclomatic 31) · ×1
  • OpenAIServerConversationTracker.prepare_input (cyclomatic 31) src/agents/run_internal/oai_conversation.py:518 — OpenAIServerConversationTracker.prepare_input has cyclomatic complexity 31 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AnyLLMModel._fetch_chat_response (cyclomatic 30) · ×1
  • AnyLLMModel._fetch_chat_response (cyclomatic 30) src/agents/extensions/models/any_llm_model.py:846 — AnyLLMModel._fetch_chat_response has cyclomatic complexity 30 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · AnyLLMModel._fix_tool_message_ordering (cyclomatic 30) · ×1
  • AnyLLMModel._fix_tool_message_ordering (cyclomatic 30) src/agents/extensions/models/any_llm_model.py:1503 — AnyLLMModel._fix_tool_message_ordering has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LitellmModel._fix_tool_message_ordering (cyclomatic 30) · ×1
  • LitellmModel._fix_tool_message_ordering (cyclomatic 30) src/agents/extensions/models/litellm_model.py:742 — LitellmModel._fix_tool_message_ordering has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · MCPServerStreamableHttp.call_tool (cyclomatic 30) · ×1
  • MCPServerStreamableHttp.call_tool (cyclomatic 30) src/agents/mcp/server.py:2550 — MCPServerStreamableHttp.call_tool has cyclomatic complexity 30 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · CodexExec.run (cyclomatic 29) · ×1
  • CodexExec.run (cyclomatic 29) src/agents/extensions/experimental/codex/exec.py:61 — CodexExec.run has cyclomatic complexity 29 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · LitellmModel._fetch_response (cyclomatic 29) · ×1
  • LitellmModel._fetch_response (cyclomatic 29) src/agents/extensions/models/litellm_model.py:506 — LitellmModel._fetch_response has cyclomatic complexity 29 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · RealtimeSession._run_output_guardrails (cyclomatic 29) · ×1
  • RealtimeSession._run_output_guardrails (cyclomatic 29) src/agents/realtime/session.py:1682 — RealtimeSession._run_output_guardrails has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunContextWrapper.get_rejection_message (cyclomatic 29) · ×1
  • RunContextWrapper.get_rejection_message (cyclomatic 29) src/agents/run_context.py:1090 — RunContextWrapper.get_rejection_message has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · run_loop._finalize_streamed_final_output (cyclomatic 29) · ×1
  • run_loop._finalize_streamed_final_output (cyclomatic 29) src/agents/run_internal/run_loop.py:556 — run_loop._finalize_streamed_final_output has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · tool_execution.collect_manual_mcp_approvals (cyclomatic 29) · ×1
  • tool_execution.collect_manual_mcp_approvals (cyclomatic 29) src/agents/run_internal/tool_execution.py:1402 — tool_execution.collect_manual_mcp_approvals has cyclomatic complexity 29 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · _run_state_agent_identity._normalize_capability_identity_value (cyclomatic 28) · ×1
  • _run_state_agent_identity._normalize_capability_identity_value (cyclomatic 28) src/agents/_run_state_agent_identity.py:208 — _run_state_agent_identity._normalize_capability_identity_value has cyclomatic complexity 28 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Agent.__post_init__ (cyclomatic 28) · ×1
  • Agent.__post_init__ (cyclomatic 28) src/agents/agent.py:459 — Agent.__post_init__ has cyclomatic complexity 28 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · LitellmModel.get_response (cyclomatic 28) · ×1
  • LitellmModel.get_response (cyclomatic 28) src/agents/extensions/models/litellm_model.py:215 — LitellmModel.get_response has cyclomatic complexity 28 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · StreamedAudioResult.stream (cyclomatic 28) · ×1
  • StreamedAudioResult.stream (cyclomatic 28) src/agents/voice/result.py:397 — StreamedAudioResult.stream has cyclomatic complexity 28 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · session_persistence.prepare_input_with_session (cyclomatic 27) · ×1
  • session_persistence.prepare_input_with_session (cyclomatic 27) src/agents/run_internal/session_persistence.py:424 — session_persistence.prepare_input_with_session has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunState._find_nested_approval_state (cyclomatic 27) · ×1
  • RunState._find_nested_approval_state (cyclomatic 27) src/agents/run_state.py:1220 — RunState._find_nested_approval_state has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · BackendSpanExporter._export_with_deadline (cyclomatic 27) · ×1
  • BackendSpanExporter._export_with_deadline (cyclomatic 27) src/agents/tracing/processors.py:134 — BackendSpanExporter._export_with_deadline has cyclomatic complexity 27 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · check_optional_truthiness._reference_bindings_for_scope (cyclomatic 26) · ×1
  • check_optional_truthiness._reference_bindings_for_scope (cyclomatic 26) .github/scripts/check_optional_truthiness.py:192 — check_optional_truthiness._reference_bindings_for_scope has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · _tool_invocation.tool_invocation_identity_and_scope (cyclomatic 26) · ×1
  • _tool_invocation.tool_invocation_identity_and_scope (cyclomatic 26) src/agents/_tool_invocation.py:165 — _tool_invocation.tool_invocation_identity_and_scope has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Converter.extract_all_content (cyclomatic 26) · ×1
  • Converter.extract_all_content (cyclomatic 26) src/agents/models/chatcmpl_converter.py:444 — Converter.extract_all_content has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIChatCompletionsModel._fetch_response (cyclomatic 26) · ×1
  • OpenAIChatCompletionsModel._fetch_response (cyclomatic 26) src/agents/models/openai_chatcompletions.py:605 — OpenAIChatCompletionsModel._fetch_response has cyclomatic complexity 26 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · OpenAIResponsesModel.stream_response (cyclomatic 26) · ×1
  • OpenAIResponsesModel.stream_response (cyclomatic 26) src/agents/models/openai_responses.py:683 — OpenAIResponsesModel.stream_response has cyclomatic complexity 26 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIChatCompletionsModel.get_response (cyclomatic 25) · ×1
  • OpenAIChatCompletionsModel.get_response (cyclomatic 25) src/agents/models/openai_chatcompletions.py:216 — OpenAIChatCompletionsModel.get_response has cyclomatic complexity 25 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · RunState._merge_generated_items_with_processed (cyclomatic 25) · ×1
  • RunState._merge_generated_items_with_processed (cyclomatic 25) src/agents/run_state.py:1842 — RunState._merge_generated_items_with_processed has cyclomatic complexity 25 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · _run_state_agent_identity._iter_agent_graph (cyclomatic 24) · ×1
  • _run_state_agent_identity._iter_agent_graph (cyclomatic 24) src/agents/_run_state_agent_identity.py:30 — _run_state_agent_identity._iter_agent_graph has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · DefaultTraceProvider.create_span (cyclomatic 24) · ×1
  • DefaultTraceProvider.create_span (cyclomatic 24) src/agents/tracing/provider.py:404 — DefaultTraceProvider.create_span has cyclomatic complexity 24 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · codex_tool.codex_tool (cyclomatic 23) · ×1
  • codex_tool.codex_tool (cyclomatic 23) src/agents/extensions/experimental/codex/codex_tool.py:237 — codex_tool.codex_tool has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · OpenAIResponsesModel._build_response_create_kwargs (cyclomatic 23) · ×1
  • OpenAIResponsesModel._build_response_create_kwargs (cyclomatic 23) src/agents/models/openai_responses.py:923 — OpenAIResponsesModel._build_response_create_kwargs has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · run_state._run_state_raw_items (cyclomatic 23) · ×1
  • run_state._run_state_raw_items (cyclomatic 23) src/agents/run_state.py:3897 — run_state._run_state_raw_items has cyclomatic complexity 23 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · tool._normalize_function_tool_callable (cyclomatic 23) · ×1
  • tool._normalize_function_tool_callable (cyclomatic 23) src/agents/tool.py:2507 — tool._normalize_function_tool_callable has cyclomatic complexity 23 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · apply_diff._read_section (cyclomatic 22) · ×1
  • apply_diff._read_section (cyclomatic 22) src/agents/apply_diff.py:250 — apply_diff._read_section has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ChatCmplStreamHandler.buffer_tool_call_stream (cyclomatic 22) · ×1
  • ChatCmplStreamHandler.buffer_tool_call_stream (cyclomatic 22) src/agents/models/chatcmpl_stream_handler.py:392 — ChatCmplStreamHandler.buffer_tool_call_stream has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunContextWrapper._matching_sticky_approval_keys (cyclomatic 22) · ×1
  • RunContextWrapper._matching_sticky_approval_keys (cyclomatic 22) src/agents/run_context.py:659 — RunContextWrapper._matching_sticky_approval_keys has cyclomatic complexity 22 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · model._stream_events_for_step (cyclomatic 22) · ×1
  • model._stream_events_for_step (cyclomatic 22) src/agents/testing/model.py:781 — model._stream_events_for_step has cyclomatic complexity 22 (threshold 15). To reduce it, separate the branches: extract each independent case into its own named function so the top-level body reads as a short sequence of named decisions.
D1 · Cyclomatic Complexity · validate_handoff.validate (cyclomatic 21) · ×1
  • validate_handoff.validate (cyclomatic 21) .agents/skills/implementation-kickoff/scripts/validate_handoff.py:146 — validate_handoff.validate has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · AnyLLMModel._get_response_via_chat (cyclomatic 21) · ×1
  • AnyLLMModel._get_response_via_chat (cyclomatic 21) src/agents/extensions/models/any_llm_model.py:580 — AnyLLMModel._get_response_via_chat has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · _MCPServerWithClientSession.connect (cyclomatic 21) · ×1
  • _MCPServerWithClientSession.connect (cyclomatic 21) src/agents/mcp/server.py:1376 — _MCPServerWithClientSession.connect has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · _MCPServerWithClientSession.list_tools (cyclomatic 21) · ×1
  • _MCPServerWithClientSession.list_tools (cyclomatic 21) src/agents/mcp/server.py:1474 — _MCPServerWithClientSession.list_tools has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Converter._validate_named_function_tool_choice (cyclomatic 21) · ×1
  • Converter._validate_named_function_tool_choice (cyclomatic 21) src/agents/models/openai_responses.py:1939 — Converter._validate_named_function_tool_choice has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunContextWrapper._restore_pending_approval_binding (cyclomatic 21) · ×1
  • RunContextWrapper._restore_pending_approval_binding (cyclomatic 21) src/agents/run_context.py:770 — RunContextWrapper._restore_pending_approval_binding has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · items.reconcile_nested_history_owned_input_after_rewrite (cyclomatic 21) · ×1
  • items.reconcile_nested_history_owned_input_after_rewrite (cyclomatic 21) src/agents/run_internal/items.py:500 — items.reconcile_nested_history_owned_input_after_rewrite has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · model._validate_model_step (cyclomatic 21) · ×1
  • model._validate_model_step (cyclomatic 21) src/agents/testing/model.py:709 — model._validate_model_step has cyclomatic complexity 21 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · OpenAISTTTranscriptionSession._handle_events (cyclomatic 21) · ×1
  • OpenAISTTTranscriptionSession._handle_events (cyclomatic 21) src/agents/voice/models/openai_stt.py:320 — OpenAISTTTranscriptionSession._handle_events has cyclomatic complexity 21 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RedisSession._mutate_items_attempt (cyclomatic 20) · ×1
  • RedisSession._mutate_items_attempt (cyclomatic 20) src/agents/extensions/memory/redis_session.py:474 — RedisSession._mutate_items_attempt has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ToolOutputTrimmer._structured_output_details (cyclomatic 20) · ×1
  • ToolOutputTrimmer._structured_output_details (cyclomatic 20) src/agents/extensions/tool_output_trimmer.py:338 — ToolOutputTrimmer._structured_output_details has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · result._input_items_for_result (cyclomatic 20) · ×1
  • result._input_items_for_result (cyclomatic 20) src/agents/result.py:270 — result._input_items_for_result has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIServerConversationTracker.validate_pending_input_filter (cyclomatic 20) · ×1
  • OpenAIServerConversationTracker.validate_pending_input_filter (cyclomatic 20) src/agents/run_internal/oai_conversation.py:429 — OpenAIServerConversationTracker.validate_pending_input_filter has cyclomatic complexity 20 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · session_persistence.defer_interrupted_session_write (cyclomatic 20) · ×1
  • session_persistence.defer_interrupted_session_write (cyclomatic 20) src/agents/run_internal/session_persistence.py:1274 — session_persistence.defer_interrupted_session_write has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · sandbox._normalize_step (cyclomatic 20) · ×1
  • sandbox._normalize_step (cyclomatic 20) src/agents/testing/sandbox.py:213 — sandbox._normalize_step has cyclomatic complexity 20 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · review_state.review_state (cyclomatic 19) · ×1
  • review_state.review_state (cyclomatic 19) .agents/skills/implementation-final-review/scripts/review_state.py:491 — review_state.review_state has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · AnyLLMModel._stream_response_via_responses (cyclomatic 19) · ×1
  • AnyLLMModel._stream_response_via_responses (cyclomatic 19) src/agents/extensions/models/any_llm_model.py:464 — AnyLLMModel._stream_response_via_responses has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunContextWrapper._rebuild_hosted_mcp_approvals (cyclomatic 19) · ×1
  • RunContextWrapper._rebuild_hosted_mcp_approvals (cyclomatic 19) src/agents/run_context.py:1660 — RunContextWrapper._rebuild_hosted_mcp_approvals has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIServerConversationTracker.track_server_items (cyclomatic 19) · ×1
  • OpenAIServerConversationTracker.track_server_items (cyclomatic 19) src/agents/run_internal/oai_conversation.py:350 — OpenAIServerConversationTracker.track_server_items has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · session_persistence.rewind_session_items (cyclomatic 19) · ×1
  • session_persistence.rewind_session_items (cyclomatic 19) src/agents/run_internal/session_persistence.py:1622 — session_persistence.rewind_session_items has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · tool_planning._register_tool_call_items (cyclomatic 19) · ×1
  • tool_planning._register_tool_call_items (cyclomatic 19) src/agents/run_internal/tool_planning.py:273 — tool_planning._register_tool_call_items has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunState._serialize_item (cyclomatic 19) · ×1
  • RunState._serialize_item (cyclomatic 19) src/agents/run_state.py:2172 — RunState._serialize_item has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · run_state._restore_pydantic_fields_set (cyclomatic 19) · ×1
  • run_state._restore_pydantic_fields_set (cyclomatic 19) src/agents/run_state.py:723 — run_state._restore_pydantic_fields_set has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ToolContext._find_nested_approval_target (cyclomatic 19) · ×1
  • ToolContext._find_nested_approval_target (cyclomatic 19) src/agents/tool_context.py:127 — ToolContext._find_nested_approval_target has cyclomatic complexity 19 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · StreamedAudioResult._stream_audio (cyclomatic 19) · ×1
  • StreamedAudioResult._stream_audio (cyclomatic 19) src/agents/voice/result.py:143 — StreamedAudioResult._stream_audio has cyclomatic complexity 19 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · review_protocol._review_state (cyclomatic 18) · ×1
  • review_protocol._review_state (cyclomatic 18) .agents/skills/implementation-final-review/scripts/review_protocol.py:391 — review_protocol._review_state has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · release_automation.main (cyclomatic 18) · ×1
  • release_automation.main (cyclomatic 18) .github/scripts/release_automation.py:356 — release_automation.main has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · _tool_identity.resolve_tool_name_collisions (cyclomatic 18) · ×1
  • _tool_identity.resolve_tool_name_collisions (cyclomatic 18) src/agents/_tool_identity.py:503 — _tool_identity.resolve_tool_name_collisions has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · _tool_identity.get_function_tool_approval_keys (cyclomatic 18) · ×1
  • _tool_identity.get_function_tool_approval_keys (cyclomatic 18) src/agents/_tool_identity.py:607 — _tool_identity.get_function_tool_approval_keys has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · history._get_nested_history_owned_items (cyclomatic 18) · ×1
  • history._get_nested_history_owned_items (cyclomatic 18) src/agents/handoffs/history.py:170 — history._get_nested_history_owned_items has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunResultStreaming._check_errors (cyclomatic 18) · ×1
  • RunResultStreaming._check_errors (cyclomatic 18) src/agents/result.py:1172 — RunResultStreaming._check_errors has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · _FunctionToolBatchExecutor._maybe_execute_tool_approval (cyclomatic 18) · ×1
  • _FunctionToolBatchExecutor._maybe_execute_tool_approval (cyclomatic 18) src/agents/run_internal/tool_execution.py:1875 — _FunctionToolBatchExecutor._maybe_execute_tool_approval has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · _FunctionToolBatchExecutor._invoke_tool_and_run_post_invoke (cyclomatic 18) · ×1
  • _FunctionToolBatchExecutor._invoke_tool_and_run_post_invoke (cyclomatic 18) src/agents/run_internal/tool_execution.py:2079 — _FunctionToolBatchExecutor._invoke_tool_and_run_post_invoke has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · tool_execution.coerce_shell_call (cyclomatic 18) · ×1
  • tool_execution.coerce_shell_call (cyclomatic 18) src/agents/run_internal/tool_execution.py:652 — tool_execution.coerce_shell_call has cyclomatic complexity 18 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · BackendSpanExporter._sanitize_for_openai_tracing_api (cyclomatic 18) · ×1
  • BackendSpanExporter._sanitize_for_openai_tracing_api (cyclomatic 18) src/agents/tracing/processors.py:337 — BackendSpanExporter._sanitize_for_openai_tracing_api has cyclomatic complexity 18 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · LitellmModel._convert_gemini_extra_content_to_provider_specific_fields (cyclomatic 17) · ×1
  • LitellmModel._convert_gemini_extra_content_to_provider_specific_fields (cyclomatic 17) src/agents/extensions/models/litellm_model.py:683 — LitellmModel._convert_gemini_extra_content_to_provider_specific_fields has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ToolOutputTrimmer._trim_json_schema (cyclomatic 17) · ×1
  • ToolOutputTrimmer._trim_json_schema (cyclomatic 17) src/agents/extensions/tool_output_trimmer.py:457 — ToolOutputTrimmer._trim_json_schema has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · ModelSettings.resolve (cyclomatic 17) · ×1
  • ModelSettings.resolve (cyclomatic 17) src/agents/model_settings.py:260 — ModelSettings.resolve has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · OpenAIResponsesWSModel.get_retry_advice (cyclomatic 17) · ×1
  • OpenAIResponsesWSModel.get_retry_advice (cyclomatic 17) src/agents/models/openai_responses.py:1186 — OpenAIResponsesWSModel.get_retry_advice has cyclomatic complexity 17 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: Converter.convert_tool_choice (cyclomatic 20) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · strict_schema._json_values_equal (cyclomatic 17) · ×1
  • strict_schema._json_values_equal (cyclomatic 17) src/agents/strict_schema.py:510 — strict_schema._json_values_equal has cyclomatic complexity 17 (threshold 15). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D1 · Cyclomatic Complexity · _function_tool_arguments._is_data_only_schema (cyclomatic 16) · ×1
  • _function_tool_arguments._is_data_only_schema (cyclomatic 16) src/agents/_function_tool_arguments.py:71 — _function_tool_arguments._is_data_only_schema has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · events.coerce_thread_event (cyclomatic 16) · ×1
  • events.coerce_thread_event (cyclomatic 16) src/agents/extensions/experimental/codex/events.py:111 — events.coerce_thread_event has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · OpenAIHostedMultiAgentModel._prepare_websocket_request (cyclomatic 16) · ×1
  • OpenAIHostedMultiAgentModel._prepare_websocket_request (cyclomatic 16) src/agents/extensions/experimental/hosted_multi_agent/model.py:478 — OpenAIHostedMultiAgentModel._prepare_websocket_request has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · visualization._get_all_nodes (cyclomatic 16) · ×1
  • visualization._get_all_nodes (cyclomatic 16) src/agents/extensions/visualization.py:194 — visualization._get_all_nodes has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · _ServerWorker._run (cyclomatic 16) · ×1
  • _ServerWorker._run (cyclomatic 16) src/agents/mcp/manager.py:158 — _ServerWorker._run has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · Converter.convert_tools (cyclomatic 16) · ×1
  • Converter.convert_tools (cyclomatic 16) src/agents/models/openai_responses.py:2115 — Converter.convert_tools has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top. This is NOT this file's highest cyclomatic complexity: Converter.convert_tool_choice (cyclomatic 20) is higher and carries no row of its own — it was excluded as a flat dispatcher (a long switch/match over independent cases: many branches, almost no nesting), which this dimension does not treat as a refactor obligation. It is named here so the ranking you see in this file is not mistaken for the whole of it; the excluded method is counted neither in this dimension's figures nor in its score.
D1 · Cyclomatic Complexity · audio_formats.to_realtime_audio_format (cyclomatic 16) · ×1
  • audio_formats.to_realtime_audio_format (cyclomatic 16) src/agents/realtime/audio_formats.py:17 — audio_formats.to_realtime_audio_format has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RealtimeSession._maybe_request_tool_approval (cyclomatic 16) · ×1
  • RealtimeSession._maybe_request_tool_approval (cyclomatic 16) src/agents/realtime/session.py:704 — RealtimeSession._maybe_request_tool_approval has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunResultStreaming.stream_events (cyclomatic 16) · ×1
  • RunResultStreaming.stream_events (cyclomatic 16) src/agents/result.py:1005 — RunResultStreaming.stream_events has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunContextWrapper._approval_records_for_key (cyclomatic 16) · ×1
  • RunContextWrapper._approval_records_for_key (cyclomatic 16) src/agents/run_context.py:436 — RunContextWrapper._approval_records_for_key has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · tool_execution.normalize_shell_output (cyclomatic 16) · ×1
  • tool_execution.normalize_shell_output (cyclomatic 16) src/agents/run_internal/tool_execution.py:893 — tool_execution.normalize_shell_output has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · turn_resolution._completed_tool_step_items (cyclomatic 16) · ×1
  • turn_resolution._completed_tool_step_items (cyclomatic 16) src/agents/run_internal/turn_resolution.py:901 — turn_resolution._completed_tool_step_items has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D1 · Cyclomatic Complexity · RunState._serialize_context_payload (cyclomatic 16) · ×1
  • RunState._serialize_context_payload (cyclomatic 16) src/agents/run_state.py:1651 — RunState._serialize_context_payload has cyclomatic complexity 16 (threshold 15). To reduce it, split the body: these branches sit side by side rather than nested inside one another, so extracting each one on its own would leave a function per branch. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D1 · Cyclomatic Complexity · run_state._run_state_program_call_ids (cyclomatic 16) · ×1
  • run_state._run_state_program_call_ids (cyclomatic 16) src/agents/run_state.py:3968 — run_state._run_state_program_call_ids has cyclomatic complexity 16 (threshold 15). To reduce it, separate the cases: extract each independent branch into its own named function, and where the body has guards that only reject input, fold those into early returns at the top.
D17 · Explicit Debt · FixmeComment · ×1
  • FixmeComment docs/scripts/translate_docs.py:684 — # FIXME: enable mkdocs search plugin to seamlessly work with i18n plugin — source code is not a task system: move the work to your tracker and leave a reference instead (e.g. `# REF: #123`), so the task is planned where tasks live and the ticket links back to the code.
D2 · Cognitive Complexity · AgentRunner._run_impl (cognitive 609) · ×1
  • AgentRunner._run_impl (cognitive 609) src/agents/run.py:629 — AgentRunner._run_impl has cognitive complexity 609 (threshold 15). Drivers by points: if/else 133 (407 pts), ternaries 32 (71 pts), error handling 20 (61 pts), boolean chains 56, loops 4 (14 pts) (nesting depth added 364). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · run_loop.start_streaming (cognitive 474) · ×1
  • run_loop.start_streaming (cognitive 474) src/agents/run_internal/run_loop.py:987 — run_loop.start_streaming has cognitive complexity 474 (threshold 15). Drivers by points: if/else 127 (331 pts), ternaries 26 (64 pts), boolean chains 32, error handling 14 (32 pts), loops 5 (15 pts) (nesting depth added 270). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · ChatCmplStreamHandler.handle_stream (cognitive 319) · ×1
  • ChatCmplStreamHandler.handle_stream (cognitive 319) src/agents/models/chatcmpl_stream_handler.py:603 — ChatCmplStreamHandler.handle_stream has cognitive complexity 319 (threshold 15). Drivers by points: if/else 86 (248 pts), boolean chains 33, ternaries 5 (26 pts), loops 6 (12 pts) (nesting depth added 189). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · turn_resolution.resolve_interrupted_turn (cognitive 235) · ×1
  • turn_resolution.resolve_interrupted_turn (cognitive 235) src/agents/run_internal/turn_resolution.py:1387 — turn_resolution.resolve_interrupted_turn has cognitive complexity 235 (threshold 15). Drivers by points: if/else 79 (138 pts), boolean chains 37, loops 35 (36 pts), ternaries 12 (22 pts), error handling 2 (nesting depth added 70). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Converter.items_to_messages (cognitive 193) · ×1
  • Converter.items_to_messages (cognitive 193) src/agents/models/chatcmpl_converter.py:548 — Converter.items_to_messages has cognitive complexity 193 (threshold 15). Drivers by points: if/else 42 (145 pts), loops 5 (18 pts), ternaries 5 (16 pts), boolean chains 14 (nesting depth added 127). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · turn_resolution.process_model_response (cognitive 192) · ×1
  • turn_resolution.process_model_response (cognitive 192) src/agents/run_internal/turn_resolution.py:3158 — turn_resolution.process_model_response has cognitive complexity 192 (threshold 15). Drivers by points: if/else 60 (132 pts), ternaries 13 (38 pts), boolean chains 17, loops 2 (5 pts) (nesting depth added 100). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RealtimeSession._get_new_history (cognitive 191) · ×1
  • RealtimeSession._get_new_history (cognitive 191) src/agents/realtime/session.py:1506 — RealtimeSession._get_new_history has cognitive complexity 191 (threshold 15). Drivers by points: if/else 36 (140 pts), loops 7 (31 pts), boolean chains 13, ternaries 1 (7 pts) (nesting depth added 134). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · review_protocol.validate_packet (cognitive 174) · ×1
  • review_protocol.validate_packet (cognitive 174) .agents/skills/implementation-final-review/scripts/review_protocol.py:526 — review_protocol.validate_packet has cognitive complexity 174 (threshold 15). Drivers by points: if/else 70 (126 pts), loops 18 (28 pts), boolean chains 20 (nesting depth added 66). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_state._build_run_state_from_json (cognitive 172) · ×1
  • run_state._build_run_state_from_json (cognitive 172) src/agents/run_state.py:4174 — run_state._build_run_state_from_json has cognitive complexity 172 (threshold 15). Drivers by points: if/else 63 (105 pts), boolean chains 38, loops 7 (14 pts), ternaries 9 (13 pts), error handling 1 (2 pts) (nesting depth added 54). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIServerConversationTracker.hydrate_from_state (cognitive 113) · ×1
  • OpenAIServerConversationTracker.hydrate_from_state (cognitive 113) src/agents/run_internal/oai_conversation.py:177 — OpenAIServerConversationTracker.hydrate_from_state has cognitive complexity 113 (threshold 15). Drivers by points: if/else 33 (84 pts), boolean chains 14, ternaries 3 (8 pts), loops 5 (7 pts) (nesting depth added 58). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_state._validate_completed_tool_invocations (cognitive 109) · ×1
  • run_state._validate_completed_tool_invocations (cognitive 109) src/agents/run_state.py:4820 — run_state._validate_completed_tool_invocations has cognitive complexity 109 (threshold 15). Drivers by points: if/else 26 (59 pts), loops 23 (43 pts), error handling 1 (4 pts), boolean chains 3 (nesting depth added 56). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · turn_resolution.execute_tools_and_side_effects (cognitive 101) · ×1
  • turn_resolution.execute_tools_and_side_effects (cognitive 101) src/agents/run_internal/turn_resolution.py:966 — turn_resolution.execute_tools_and_side_effects has cognitive complexity 101 (threshold 15). Drivers by points: if/else 26 (82 pts), boolean chains 7, error handling 3 (7 pts), ternaries 5 (nesting depth added 60). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · RealtimeSession.on_event (cognitive 100) · ×1
  • RealtimeSession.on_event (cognitive 100) src/agents/realtime/session.py:412 — RealtimeSession.on_event has cognitive complexity 100 (threshold 15). Drivers by points: if/else 30 (80 pts), boolean chains 11, error handling 2 (6 pts), loops 1 (3 pts) (nesting depth added 56). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · OpenAIResponsesCompactionSession._run_compaction_locked (cognitive 92) · ×1
  • OpenAIResponsesCompactionSession._run_compaction_locked (cognitive 92) src/agents/memory/openai_responses_compaction_session.py:273 — OpenAIResponsesCompactionSession._run_compaction_locked has cognitive complexity 92 (threshold 15). Drivers by points: if/else 32 (55 pts), boolean chains 22, ternaries 6 (11 pts), error handling 1 (2 pts), loops 1 (2 pts) (nesting depth added 30). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunContextWrapper.get_approval_status (cognitive 92) · ×1
  • RunContextWrapper.get_approval_status (cognitive 92) src/agents/run_context.py:1369 — RunContextWrapper.get_approval_status has cognitive complexity 92 (threshold 15). Drivers by points: if/else 28 (52 pts), ternaries 13 (20 pts), boolean chains 14, loops 4 (6 pts) (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_state._copy_pydantic_value (cognitive 90) · ×1
  • run_state._copy_pydantic_value (cognitive 90) src/agents/run_state.py:446 — run_state._copy_pydantic_value has cognitive complexity 90 (threshold 15). Drivers by points: if/else 31 (72 pts), loops 7 (16 pts), boolean chains 2 (nesting depth added 50). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunContextWrapper._apply_approval_decision (cognitive 89) · ×1
  • RunContextWrapper._apply_approval_decision (cognitive 89) src/agents/run_context.py:1180 — RunContextWrapper._apply_approval_decision has cognitive complexity 89 (threshold 15). Drivers by points: if/else 33 (58 pts), ternaries 9 (19 pts), boolean chains 11, loops 1 (nesting depth added 35). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · review_protocol.validate_reviewer_output (cognitive 86) · ×1
  • review_protocol.validate_reviewer_output (cognitive 86) .agents/skills/implementation-final-review/scripts/review_protocol.py:1030 — review_protocol.validate_reviewer_output has cognitive complexity 86 (threshold 15). Drivers by points: if/else 29 (61 pts), boolean chains 10, loops 6 (9 pts), ternaries 2 (6 pts) (nesting depth added 39). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · model_retry.stream_response_with_retry (cognitive 85) · ×1
  • model_retry.stream_response_with_retry (cognitive 85) src/agents/run_internal/model_retry.py:684 — model_retry.stream_response_with_retry has cognitive complexity 85 (threshold 15). Drivers by points: if/else 17 (49 pts), ternaries 5 (14 pts), error handling 4 (13 pts), boolean chains 6, loops 2 (3 pts) (nesting depth added 51). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIRealtimeWebSocketModel._handle_ws_event (cognitive 84) · ×1
  • OpenAIRealtimeWebSocketModel._handle_ws_event (cognitive 84) src/agents/realtime/openai_realtime.py:1370 — OpenAIRealtimeWebSocketModel._handle_ws_event has cognitive complexity 84 (threshold 15). Drivers by points: if/else 24 (58 pts), boolean chains 14, ternaries 3 (7 pts), loops 1 (3 pts), error handling 2 (nesting depth added 40). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · LitellmModel._fix_tool_message_ordering (cognitive 80) · ×1
  • LitellmModel._fix_tool_message_ordering (cognitive 80) src/agents/extensions/models/litellm_model.py:742 — LitellmModel._fix_tool_message_ordering has cognitive complexity 80 (threshold 15). Drivers by points: if/else 19 (57 pts), loops 6 (19 pts), boolean chains 4 (nesting depth added 51). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · _run_state_agent_identity._iter_agent_graph (cognitive 73) · ×1
  • _run_state_agent_identity._iter_agent_graph (cognitive 73) src/agents/_run_state_agent_identity.py:30 — _run_state_agent_identity._iter_agent_graph has cognitive complexity 73 (threshold 15). Drivers by points: if/else 15 (50 pts), ternaries 3 (13 pts), loops 3 (6 pts), boolean chains 4 (nesting depth added 48). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Converter.message_to_output_items (cognitive 73) · ×1
  • Converter.message_to_output_items (cognitive 73) src/agents/models/chatcmpl_converter.py:123 — Converter.message_to_output_items has cognitive complexity 73 (threshold 15). Drivers by points: if/else 23 (59 pts), boolean chains 5, loops 2 (5 pts), ternaries 3 (4 pts) (nesting depth added 40). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · AnyLLMModel._fix_tool_message_ordering (cognitive 72) · ×1
  • AnyLLMModel._fix_tool_message_ordering (cognitive 72) src/agents/extensions/models/any_llm_model.py:1503 — AnyLLMModel._fix_tool_message_ordering has cognitive complexity 72 (threshold 15). Drivers by points: if/else 16 (49 pts), loops 6 (18 pts), boolean chains 5 (nesting depth added 45). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · function_schema.function_schema (cognitive 70) · ×1
  • function_schema.function_schema (cognitive 70) src/agents/function_schema.py:321 — function_schema.function_schema has cognitive complexity 70 (threshold 15). Drivers by points: if/else 24 (49 pts), boolean chains 13, loops 4, ternaries 3 (4 pts) (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIHostedMultiAgentModel._iter_websocket_turn (cognitive 67) · ×1
  • OpenAIHostedMultiAgentModel._iter_websocket_turn (cognitive 67) src/agents/extensions/experimental/hosted_multi_agent/model.py:733 — OpenAIHostedMultiAgentModel._iter_websocket_turn has cognitive complexity 67 (threshold 15). Drivers by points: if/else 23 (51 pts), ternaries 3 (7 pts), boolean chains 5, loops 2 (3 pts), error handling 1 (nesting depth added 33). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIResponsesWSModel._iter_websocket_response_events (cognitive 67) · ×1
  • OpenAIResponsesWSModel._iter_websocket_response_events (cognitive 67) src/agents/models/openai_responses.py:1360 — OpenAIResponsesWSModel._iter_websocket_response_events has cognitive complexity 67 (threshold 15). Drivers by points: if/else 18 (49 pts), boolean chains 9, ternaries 1 (4 pts), loops 2 (3 pts), error handling 1 (2 pts) (nesting depth added 36). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIRealtimeWebSocketModel._interrupt_audio_playback (cognitive 66) · ×1
  • OpenAIRealtimeWebSocketModel._interrupt_audio_playback (cognitive 66) src/agents/realtime/openai_realtime.py:1044 — OpenAIRealtimeWebSocketModel._interrupt_audio_playback has cognitive complexity 66 (threshold 15). Drivers by points: if/else 17 (35 pts), error handling 3 (11 pts), boolean chains 10, ternaries 3 (8 pts), loops 1 (2 pts) (nesting depth added 32). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · RealtimeSession._handle_tool_call (cognitive 65) · ×1
  • RealtimeSession._handle_tool_call (cognitive 65) src/agents/realtime/session.py:1096 — RealtimeSession._handle_tool_call has cognitive complexity 65 (threshold 15). Drivers by points: if/else 27 (41 pts), boolean chains 15, ternaries 8 (9 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · codex_tool._enforce_span_data_budget (cognitive 63) · ×1
  • codex_tool._enforce_span_data_budget (cognitive 63) src/agents/extensions/experimental/codex/codex_tool.py:1313 — codex_tool._enforce_span_data_budget has cognitive complexity 63 (threshold 15). Drivers by points: if/else 27 (42 pts), loops 10 (17 pts), boolean chains 4 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · turn_resolution._preflight_response_invocations_after_processing_error (cognitive 61) · ×1
  • turn_resolution._preflight_response_invocations_after_processing_error (cognitive 61) src/agents/run_internal/turn_resolution.py:3918 — turn_resolution._preflight_response_invocations_after_processing_error has cognitive complexity 61 (threshold 15). Drivers by points: if/else 17 (32 pts), ternaries 7 (23 pts), boolean chains 5, loops 1 (nesting depth added 31). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · items.drop_orphan_function_calls (cognitive 59) · ×1
  • items.drop_orphan_function_calls (cognitive 59) src/agents/run_internal/items.py:211 — items.drop_orphan_function_calls has cognitive complexity 59 (threshold 15). Drivers by points: if/else 21 (43 pts), boolean chains 12, loops 3 (4 pts) (nesting depth added 23). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · strict_schema._ensure_strict_json_schema (cognitive 58) · ×1
  • strict_schema._ensure_strict_json_schema (cognitive 58) src/agents/strict_schema.py:156 — strict_schema._ensure_strict_json_schema has cognitive complexity 58 (threshold 15). Drivers by points: if/else 27 (39 pts), boolean chains 13, loops 2 (4 pts), ternaries 1 (2 pts) (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BackendSpanExporter._export_with_deadline (cognitive 58) · ×1
  • BackendSpanExporter._export_with_deadline (cognitive 58) src/agents/tracing/processors.py:134 — BackendSpanExporter._export_with_deadline has cognitive complexity 58 (threshold 15). Drivers by points: if/else 16 (41 pts), error handling 2 (7 pts), loops 4 (6 pts), boolean chains 4 (nesting depth added 32). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_loop._finalize_streamed_final_output (cognitive 57) · ×1
  • run_loop._finalize_streamed_final_output (cognitive 57) src/agents/run_internal/run_loop.py:556 — run_loop._finalize_streamed_final_output has cognitive complexity 57 (threshold 15). Drivers by points: if/else 21 (45 pts), error handling 5 (9 pts), boolean chains 3 (nesting depth added 28). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MCPUtil.invoke_mcp_tool (cognitive 53) · ×1
  • MCPUtil.invoke_mcp_tool (cognitive 53) REDACTED:686 — MCPUtil.invoke_mcp_tool has cognitive complexity 53 (threshold 15). Drivers by points: if/else 25 (37 pts), boolean chains 6, error handling 5 (6 pts), loops 1 (2 pts), ternaries 2 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · session_persistence.prepare_input_with_session (cognitive 53) · ×1
  • session_persistence.prepare_input_with_session (cognitive 53) src/agents/run_internal/session_persistence.py:424 — session_persistence.prepare_input_with_session has cognitive complexity 53 (threshold 15). Drivers by points: if/else 22 (42 pts), ternaries 2 (5 pts), boolean chains 4, loops 1 (2 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · session_persistence.resume_pending_session_write (cognitive 52) · ×1
  • session_persistence.resume_pending_session_write (cognitive 52) src/agents/run_internal/session_persistence.py:1444 — session_persistence.resume_pending_session_write has cognitive complexity 52 (threshold 15). Drivers by points: if/else 19 (28 pts), boolean chains 22, ternaries 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_loop.run_single_turn_streamed (cognitive 48) · ×1
  • run_loop.run_single_turn_streamed (cognitive 48) src/agents/run_internal/run_loop.py:2423 — run_loop.run_single_turn_streamed has cognitive complexity 48 (threshold 15). Drivers by points: if/else 18 (25 pts), ternaries 10 (19 pts), boolean chains 2, error handling 1, loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · tool_planning._dedupe_processed_response_invocations (cognitive 48) · ×1
  • tool_planning._dedupe_processed_response_invocations (cognitive 48) src/agents/run_internal/tool_planning.py:347 — tool_planning._dedupe_processed_response_invocations has cognitive complexity 48 (threshold 15). Drivers by points: if/else 21 (35 pts), loops 5 (7 pts), boolean chains 6 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RealtimeSession._run_output_guardrails (cognitive 47) · ×1
  • RealtimeSession._run_output_guardrails (cognitive 47) src/agents/realtime/session.py:1682 — RealtimeSession._run_output_guardrails has cognitive complexity 47 (threshold 15). Drivers by points: if/else 18 (35 pts), boolean chains 7, error handling 1 (2 pts), loops 2, ternaries 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIServerConversationTracker.prepare_input (cognitive 47) · ×1
  • OpenAIServerConversationTracker.prepare_input (cognitive 47) src/agents/run_internal/oai_conversation.py:518 — OpenAIServerConversationTracker.prepare_input has cognitive complexity 47 (threshold 15). Drivers by points: if/else 13 (26 pts), boolean chains 9, loops 5 (8 pts), ternaries 2 (4 pts) (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_state._deserialize_items (cognitive 47) · ×1
  • run_state._deserialize_items (cognitive 47) src/agents/run_state.py:5159 — run_state._deserialize_items has cognitive complexity 47 (threshold 15). Drivers by points: if/else 11 (26 pts), error handling 4 (10 pts), ternaries 3 (8 pts), boolean chains 2, loops 1 (nesting depth added 26). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · turn_resolution.execute_handoffs (cognitive 46) · ×1
  • turn_resolution.execute_handoffs (cognitive 46) src/agents/run_internal/turn_resolution.py:544 — turn_resolution.execute_handoffs has cognitive complexity 46 (threshold 15). Drivers by points: if/else 18 (26 pts), boolean chains 10, ternaries 6 (9 pts), error handling 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MCPServerStreamableHttp.call_tool (cognitive 45) · ×1
  • MCPServerStreamableHttp.call_tool (cognitive 45) src/agents/mcp/server.py:2550 — MCPServerStreamableHttp.call_tool has cognitive complexity 45 (threshold 15). Drivers by points: if/else 14 (30 pts), boolean chains 7, error handling 5 (7 pts), loops 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ChatCmplStreamHandler.buffer_tool_call_stream (cognitive 44) · ×1
  • ChatCmplStreamHandler.buffer_tool_call_stream (cognitive 44) src/agents/models/chatcmpl_stream_handler.py:392 — ChatCmplStreamHandler.buffer_tool_call_stream has cognitive complexity 44 (threshold 15). Drivers by points: if/else 11 (29 pts), loops 3 (7 pts), boolean chains 5, ternaries 1 (3 pts) (nesting depth added 24). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · tool_execution.collect_manual_mcp_approvals (cognitive 44) · ×1
  • tool_execution.collect_manual_mcp_approvals (cognitive 44) src/agents/run_internal/tool_execution.py:1402 — tool_execution.collect_manual_mcp_approvals has cognitive complexity 44 (threshold 15). Drivers by points: if/else 14 (29 pts), boolean chains 12, ternaries 1 (2 pts), loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_state._run_state_raw_items (cognitive 44) · ×1
  • run_state._run_state_raw_items (cognitive 44) src/agents/run_state.py:3897 — run_state._run_state_raw_items has cognitive complexity 44 (threshold 15). Drivers by points: if/else 15 (34 pts), loops 5 (8 pts), boolean chains 2 (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LitellmModel._convert_gemini_extra_content_to_provider_specific_fields (cognitive 43) · ×1
  • LitellmModel._convert_gemini_extra_content_to_provider_specific_fields (cognitive 43) src/agents/extensions/models/litellm_model.py:683 — LitellmModel._convert_gemini_extra_content_to_provider_specific_fields has cognitive complexity 43 (threshold 15). Drivers by points: if/else 9 (34 pts), loops 3 (5 pts), boolean chains 4 (nesting depth added 27). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · OpenAIResponsesModel.stream_response (cognitive 43) · ×1
  • OpenAIResponsesModel.stream_response (cognitive 43) src/agents/models/openai_responses.py:683 — OpenAIResponsesModel.stream_response has cognitive complexity 43 (threshold 15). Drivers by points: if/else 13 (28 pts), error handling 4 (5 pts), ternaries 2 (5 pts), boolean chains 4, loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Converter._convert_tool (cognitive 43) · ×1
  • Converter._convert_tool (cognitive 43) src/agents/models/openai_responses.py:2252 — Converter._convert_tool has cognitive complexity 43 (threshold 15). Drivers by points: if/else 17 (33 pts), ternaries 4 (8 pts), boolean chains 2 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · session_persistence.save_result_to_session (cognitive 42) · ×1
  • session_persistence.save_result_to_session (cognitive 42) src/agents/run_internal/session_persistence.py:778 — session_persistence.save_result_to_session has cognitive complexity 42 (threshold 15). Drivers by points: if/else 20 (28 pts), ternaries 6, boolean chains 5, loops 3 (nesting depth added 8). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · StreamedAudioResult._stream_audio (cognitive 41) · ×1
  • StreamedAudioResult._stream_audio (cognitive 41) src/agents/voice/result.py:143 — StreamedAudioResult._stream_audio has cognitive complexity 41 (threshold 15). Drivers by points: if/else 17 (35 pts), ternaries 3 (4 pts), error handling 1, loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Converter.extract_all_content (cognitive 39) · ×1
  • Converter.extract_all_content (cognitive 39) src/agents/models/chatcmpl_converter.py:444 — Converter.extract_all_content has cognitive complexity 39 (threshold 15). Drivers by points: if/else 12 (29 pts), boolean chains 9, loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _run_state_agent_identity._normalize_capability_identity_value (cognitive 38) · ×1
  • _run_state_agent_identity._normalize_capability_identity_value (cognitive 38) src/agents/_run_state_agent_identity.py:208 — _run_state_agent_identity._normalize_capability_identity_value has cognitive complexity 38 (threshold 15). Drivers by points: if/else 20 (27 pts), loops 2 (5 pts), boolean chains 4, error handling 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _MCPServerWithClientSession.connect (cognitive 38) · ×1
  • _MCPServerWithClientSession.connect (cognitive 38) src/agents/mcp/server.py:1376 — _MCPServerWithClientSession.connect has cognitive complexity 38 (threshold 15). Drivers by points: if/else 15 (24 pts), error handling 4 (7 pts), boolean chains 5, ternaries 1 (2 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · result._input_items_for_result (cognitive 38) · ×1
  • result._input_items_for_result (cognitive 38) src/agents/result.py:270 — result._input_items_for_result has cognitive complexity 38 (threshold 15). Drivers by points: if/else 13 (32 pts), boolean chains 6 (nesting depth added 19). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · RunContextWrapper.get_rejection_message (cognitive 38) · ×1
  • RunContextWrapper.get_rejection_message (cognitive 38) src/agents/run_context.py:1090 — RunContextWrapper.get_rejection_message has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (20 pts), boolean chains 6, loops 4 (6 pts), ternaries 6 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAISTTTranscriptionSession._handle_events (cognitive 38) · ×1
  • OpenAISTTTranscriptionSession._handle_events (cognitive 38) src/agents/voice/models/openai_stt.py:320 — OpenAISTTTranscriptionSession._handle_events has cognitive complexity 38 (threshold 15). Drivers by points: if/else 12 (29 pts), boolean chains 4, error handling 2 (4 pts), loops 1 (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AnyLLMModel._stream_response_via_responses (cognitive 37) · ×1
  • AnyLLMModel._stream_response_via_responses (cognitive 37) src/agents/extensions/models/any_llm_model.py:464 — AnyLLMModel._stream_response_via_responses has cognitive complexity 37 (threshold 15). Drivers by points: if/else 11 (25 pts), ternaries 2 (7 pts), error handling 2 (3 pts), boolean chains 1, loops 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_state._validate_declared_payload (cognitive 36) · ×1
  • run_state._validate_declared_payload (cognitive 36) src/agents/run_state.py:663 — run_state._validate_declared_payload has cognitive complexity 36 (threshold 15). Drivers by points: if/else 6 (22 pts), loops 3 (8 pts), boolean chains 4, error handling 1 (2 pts) (nesting depth added 22). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DefaultTraceProvider.create_span (cognitive 36) · ×1
  • DefaultTraceProvider.create_span (cognitive 36) src/agents/tracing/provider.py:404 — DefaultTraceProvider.create_span has cognitive complexity 36 (threshold 15). Drivers by points: if/else 16 (26 pts), boolean chains 8, ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · translate_docs.main (cognitive 35) · ×1
  • translate_docs.main (cognitive 35) docs/scripts/translate_docs.py:795 — translate_docs.main has cognitive complexity 35 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 4 (12 pts), boolean chains 1 (nesting depth added 20). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunContextWrapper._matching_sticky_approval_keys (cognitive 35) · ×1
  • RunContextWrapper._matching_sticky_approval_keys (cognitive 35) src/agents/run_context.py:659 — RunContextWrapper._matching_sticky_approval_keys has cognitive complexity 35 (threshold 15). Drivers by points: if/else 11 (19 pts), ternaries 4 (8 pts), boolean chains 5, loops 2 (3 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · model_retry._evaluate_retry (cognitive 35) · ×1
  • model_retry._evaluate_retry (cognitive 35) src/agents/run_internal/model_retry.py:389 — model_retry._evaluate_retry has cognitive complexity 35 (threshold 15). Drivers by points: boolean chains 14, ternaries 8 (13 pts), if/else 8 (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · tool_planning._register_tool_call_items (cognitive 35) · ×1
  • tool_planning._register_tool_call_items (cognitive 35) src/agents/run_internal/tool_planning.py:273 — tool_planning._register_tool_call_items has cognitive complexity 35 (threshold 15). Drivers by points: if/else 10 (22 pts), ternaries 3 (8 pts), loops 3, boolean chains 2 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_state._restore_current_response_item_identities (cognitive 35) · ×1
  • run_state._restore_current_response_item_identities (cognitive 35) src/agents/run_state.py:5458 — run_state._restore_current_response_item_identities has cognitive complexity 35 (threshold 15). Drivers by points: if/else 21 (23 pts), boolean chains 9, loops 3 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · AsyncSQLiteSession._get_connection (cognitive 34) · ×1
  • AsyncSQLiteSession._get_connection (cognitive 34) src/agents/extensions/memory/async_sqlite_session.py:102 — AsyncSQLiteSession._get_connection has cognitive complexity 34 (threshold 15). Drivers by points: if/else 7 (17 pts), error handling 5 (14 pts), ternaries 1 (3 pts) (nesting depth added 21). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _MCPServerWithClientSession.list_tools (cognitive 34) · ×1
  • _MCPServerWithClientSession.list_tools (cognitive 34) src/agents/mcp/server.py:1474 — _MCPServerWithClientSession.list_tools has cognitive complexity 34 (threshold 15). Drivers by points: if/else 14 (26 pts), boolean chains 4, error handling 3 (4 pts) (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIRealtimeWebSocketModel._get_session_config (cognitive 34) · ×1
  • OpenAIRealtimeWebSocketModel._get_session_config (cognitive 34) src/agents/realtime/openai_realtime.py:1737 — OpenAIRealtimeWebSocketModel._get_session_config has cognitive complexity 34 (threshold 15). Drivers by points: if/else 20 (22 pts), boolean chains 6, ternaries 6 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · _ConversionHelper.convert_user_input_to_conversation_item (cognitive 34) · ×1
  • _ConversionHelper.convert_user_input_to_conversation_item (cognitive 34) src/agents/realtime/openai_realtime.py:2090 — _ConversionHelper.convert_user_input_to_conversation_item has cognitive complexity 34 (threshold 15). Drivers by points: if/else 8 (22 pts), ternaries 1 (5 pts), error handling 1 (3 pts), boolean chains 2, loops 1 (2 pts) (nesting depth added 21). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · AgentRunner.run_streamed (cognitive 34) · ×1
  • AgentRunner.run_streamed (cognitive 34) src/agents/run.py:2632 — AgentRunner.run_streamed has cognitive complexity 34 (threshold 15). Drivers by points: ternaries 20 (21 pts), if/else 9, boolean chains 4 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · model._stream_events_for_step (cognitive 34) · ×1
  • model._stream_events_for_step (cognitive 34) src/agents/testing/model.py:781 — model._stream_events_for_step has cognitive complexity 34 (threshold 15). Drivers by points: loops 5 (15 pts), if/else 5 (9 pts), boolean chains 7, ternaries 1 (3 pts) (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LitellmModel.get_response (cognitive 33) · ×1
  • LitellmModel.get_response (cognitive 33) src/agents/extensions/models/litellm_model.py:215 — LitellmModel.get_response has cognitive complexity 33 (threshold 15). Drivers by points: if/else 12 (14 pts), boolean chains 11, ternaries 5 (8 pts) (nesting depth added 5). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · LitellmModel._fetch_response (cognitive 33) · ×1
  • LitellmModel._fetch_response (cognitive 33) src/agents/extensions/models/litellm_model.py:506 — LitellmModel._fetch_response has cognitive complexity 33 (threshold 15). Drivers by points: if/else 19 (23 pts), boolean chains 7, ternaries 2, loops 1 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · run_state._restore_pydantic_fields_set (cognitive 33) · ×1
  • run_state._restore_pydantic_fields_set (cognitive 33) src/agents/run_state.py:723 — run_state._restore_pydantic_fields_set has cognitive complexity 33 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 5 (10 pts), boolean chains 4 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MongoDBSession._pop_item (cognitive 32) · ×1
  • MongoDBSession._pop_item (cognitive 32) src/agents/extensions/memory/mongodb_session.py:413 — MongoDBSession._pop_item has cognitive complexity 32 (threshold 15). Drivers by points: error handling 7 (16 pts), if/else 7 (15 pts), loops 1 (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AnyLLMModel._fetch_chat_response (cognitive 32) · ×1
  • AnyLLMModel._fetch_chat_response (cognitive 32) src/agents/extensions/models/any_llm_model.py:846 — AnyLLMModel._fetch_chat_response has cognitive complexity 32 (threshold 15). Drivers by points: if/else 15 (17 pts), boolean chains 9, ternaries 4 (5 pts), loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ToolOutputTrimmer._trim_json_schema (cognitive 32) · ×1
  • ToolOutputTrimmer._trim_json_schema (cognitive 32) src/agents/extensions/tool_output_trimmer.py:457 — ToolOutputTrimmer._trim_json_schema has cognitive complexity 32 (threshold 15). Drivers by points: if/else 7 (14 pts), ternaries 4 (13 pts), boolean chains 4, loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunState._find_nested_approval_state (cognitive 32) · ×1
  • RunState._find_nested_approval_state (cognitive 32) src/agents/run_state.py:1220 — RunState._find_nested_approval_state has cognitive complexity 32 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 10, loops 3 (4 pts), ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _tool_identity.resolve_tool_name_collisions (cognitive 31) · ×1
  • _tool_identity.resolve_tool_name_collisions (cognitive 31) src/agents/_tool_identity.py:503 — _tool_identity.resolve_tool_name_collisions has cognitive complexity 31 (threshold 15). Drivers by points: if/else 12 (22 pts), loops 4 (5 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _tool_invocation.tool_invocation_identity_and_scope (cognitive 31) · ×1
  • _tool_invocation.tool_invocation_identity_and_scope (cognitive 31) src/agents/_tool_invocation.py:165 — _tool_invocation.tool_invocation_identity_and_scope has cognitive complexity 31 (threshold 15). Drivers by points: if/else 14 (23 pts), boolean chains 5, ternaries 1 (2 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ToolOutputTrimmer._structured_output_details (cognitive 31) · ×1
  • ToolOutputTrimmer._structured_output_details (cognitive 31) src/agents/extensions/tool_output_trimmer.py:338 — ToolOutputTrimmer._structured_output_details has cognitive complexity 31 (threshold 15). Drivers by points: if/else 11 (25 pts), boolean chains 5, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIServerConversationTracker.validate_pending_input_filter (cognitive 31) · ×1
  • OpenAIServerConversationTracker.validate_pending_input_filter (cognitive 31) src/agents/run_internal/oai_conversation.py:429 — OpenAIServerConversationTracker.validate_pending_input_filter has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 5, loops 3 (5 pts), ternaries 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunState._lookup_function_name (cognitive 31) · ×1
  • RunState._lookup_function_name (cognitive 31) src/agents/run_state.py:2232 — RunState._lookup_function_name has cognitive complexity 31 (threshold 15). Drivers by points: if/else 10 (22 pts), loops 3 (5 pts), ternaries 1 (4 pts) (nesting depth added 17). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Agent.__post_init__ (cognitive 30) · ×1
  • Agent.__post_init__ (cognitive 30) src/agents/agent.py:459 — Agent.__post_init__ has cognitive complexity 30 (threshold 15). Drivers by points: if/else 19 (22 pts), boolean chains 7, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · _ServerWorker._run (cognitive 30) · ×1
  • _ServerWorker._run (cognitive 30) src/agents/mcp/manager.py:158 — _ServerWorker._run has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (18 pts), error handling 3 (8 pts), boolean chains 2, loops 2 (nesting depth added 15). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · repl.run_demo_loop (cognitive 30) · ×1
  • repl.run_demo_loop (cognitive 30) src/agents/repl.py:15 — repl.run_demo_loop has cognitive complexity 30 (threshold 15). Drivers by points: if/else 8 (24 pts), loops 2 (4 pts), error handling 1 (2 pts) (nesting depth added 19). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunResultStreaming._check_errors (cognitive 30) · ×1
  • RunResultStreaming._check_errors (cognitive 30) src/agents/result.py:1172 — RunResultStreaming._check_errors has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 6, loops 1 (nesting depth added 13). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · RunContextWrapper._rebuild_hosted_mcp_approvals (cognitive 30) · ×1
  • RunContextWrapper._rebuild_hosted_mcp_approvals (cognitive 30) src/agents/run_context.py:1660 — RunContextWrapper._rebuild_hosted_mcp_approvals has cognitive complexity 30 (threshold 15). Drivers by points: if/else 10 (23 pts), boolean chains 6, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · model_retry.get_response_with_retry (cognitive 30) · ×1
  • model_retry.get_response_with_retry (cognitive 30) src/agents/run_internal/model_retry.py:574 — model_retry.get_response_with_retry has cognitive complexity 30 (threshold 15). Drivers by points: ternaries 4 (12 pts), if/else 3 (10 pts), boolean chains 5, error handling 1 (2 pts), loops 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · check_optional_truthiness._reference_bindings_for_scope (cognitive 29) · ×1
  • check_optional_truthiness._reference_bindings_for_scope (cognitive 29) .github/scripts/check_optional_truthiness.py:192 — check_optional_truthiness._reference_bindings_for_scope has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 9, loops 2 (4 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · release_automation.main (cognitive 29) · ×1
  • release_automation.main (cognitive 29) .github/scripts/release_automation.py:356 — release_automation.main has cognitive complexity 29 (threshold 15). Drivers by points: if/else 11 (25 pts), boolean chains 4 (nesting depth added 14). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · CodexExec.run (cognitive 29) · ×1
  • CodexExec.run (cognitive 29) src/agents/extensions/experimental/codex/exec.py:61 — CodexExec.run has cognitive complexity 29 (threshold 15). Drivers by points: if/else 21 (22 pts), loops 4 (6 pts), boolean chains 1 (nesting depth added 3). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · history._get_nested_history_owned_items (cognitive 29) · ×1
  • history._get_nested_history_owned_items (cognitive 29) src/agents/handoffs/history.py:170 — history._get_nested_history_owned_items has cognitive complexity 29 (threshold 15). Drivers by points: if/else 12 (22 pts), loops 3, boolean chains 2, ternaries 1 (2 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · tool_planning._collect_runs_by_approval (cognitive 29) · ×1
  • tool_planning._collect_runs_by_approval (cognitive 29) src/agents/run_internal/tool_planning.py:800 — tool_planning._collect_runs_by_approval has cognitive complexity 29 (threshold 15). Drivers by points: if/else 7 (14 pts), error handling 2 (6 pts), ternaries 3 (6 pts), boolean chains 2, loops 1 (nesting depth added 14). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunState._merge_generated_items_with_processed (cognitive 29) · ×1
  • RunState._merge_generated_items_with_processed (cognitive 29) src/agents/run_state.py:1842 — RunState._merge_generated_items_with_processed has cognitive complexity 29 (threshold 15). Drivers by points: if/else 10 (18 pts), boolean chains 9, loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · apply_diff._read_section (cognitive 28) · ×1
  • apply_diff._read_section (cognitive 28) src/agents/apply_diff.py:250 — apply_diff._read_section has cognitive complexity 28 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 6, ternaries 2 (4 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RedisSession._mutate_items_attempt (cognitive 28) · ×1
  • RedisSession._mutate_items_attempt (cognitive 28) src/agents/extensions/memory/redis_session.py:474 — RedisSession._mutate_items_attempt has cognitive complexity 28 (threshold 15). Drivers by points: if/else 13 (18 pts), boolean chains 5, loops 1 (3 pts), error handling 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MCPServerManager._connect_all_parallel (cognitive 28) · ×1
  • MCPServerManager._connect_all_parallel (cognitive 28) src/agents/mcp/manager.py:607 — MCPServerManager._connect_all_parallel has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 3 (6 pts), boolean chains 3 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · items.reconcile_nested_history_owned_input_after_rewrite (cognitive 28) · ×1
  • items.reconcile_nested_history_owned_input_after_rewrite (cognitive 28) src/agents/run_internal/items.py:500 — items.reconcile_nested_history_owned_input_after_rewrite has cognitive complexity 28 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 6, loops 4, ternaries 2 (4 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIServerConversationTracker.track_server_items (cognitive 28) · ×1
  • OpenAIServerConversationTracker.track_server_items (cognitive 28) src/agents/run_internal/oai_conversation.py:350 — OpenAIServerConversationTracker.track_server_items has cognitive complexity 28 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 6, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _FunctionToolBatchExecutor._build_function_tool_results (cognitive 28) · ×1
  • _FunctionToolBatchExecutor._build_function_tool_results (cognitive 28) src/agents/run_internal/tool_execution.py:2272 — _FunctionToolBatchExecutor._build_function_tool_results has cognitive complexity 28 (threshold 15). Drivers by points: if/else 6 (15 pts), ternaries 3 (12 pts), loops 1 (nesting depth added 18). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · StreamedAudioResult.stream (cognitive 28) · ×1
  • StreamedAudioResult.stream (cognitive 28) src/agents/voice/result.py:397 — StreamedAudioResult.stream has cognitive complexity 28 (threshold 15). Drivers by points: if/else 10 (14 pts), error handling 5 (8 pts), boolean chains 5, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIChatCompletionsModel.get_response (cognitive 27) · ×1
  • OpenAIChatCompletionsModel.get_response (cognitive 27) src/agents/models/openai_chatcompletions.py:216 — OpenAIChatCompletionsModel.get_response has cognitive complexity 27 (threshold 15). Drivers by points: if/else 10, ternaries 6 (9 pts), boolean chains 8 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · OpenAIChatCompletionsModel._fetch_response (cognitive 27) · ×1
  • OpenAIChatCompletionsModel._fetch_response (cognitive 27) src/agents/models/openai_chatcompletions.py:605 — OpenAIChatCompletionsModel._fetch_response has cognitive complexity 27 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 9, ternaries 5, loops 1 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · OpenAIResponsesModel._build_response_create_kwargs (cognitive 27) · ×1
  • OpenAIResponsesModel._build_response_create_kwargs (cognitive 27) src/agents/models/openai_responses.py:923 — OpenAIResponsesModel._build_response_create_kwargs has cognitive complexity 27 (threshold 15). Drivers by points: if/else 13 (15 pts), boolean chains 6, ternaries 6 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · run_state._run_state_program_call_ids (cognitive 27) · ×1
  • run_state._run_state_program_call_ids (cognitive 27) src/agents/run_state.py:3968 — run_state._run_state_program_call_ids has cognitive complexity 27 (threshold 15). Drivers by points: if/else 8 (21 pts), boolean chains 5, loops 1 (nesting depth added 13). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · BackendSpanExporter._sanitize_for_openai_tracing_api (cognitive 27) · ×1
  • BackendSpanExporter._sanitize_for_openai_tracing_api (cognitive 27) src/agents/tracing/processors.py:337 — BackendSpanExporter._sanitize_for_openai_tracing_api has cognitive complexity 27 (threshold 15). Drivers by points: if/else 15 (26 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · EncryptedSession.get_items (cognitive 26) · ×1
  • EncryptedSession.get_items (cognitive 26) src/agents/extensions/memory/encrypt_session.py:346 — EncryptedSession.get_items has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (17 pts), boolean chains 5, loops 1 (2 pts), ternaries 1 (2 pts) (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ToolCallOutputItem.to_input_item (cognitive 26) · ×1
  • ToolCallOutputItem.to_input_item (cognitive 26) src/agents/items.py:462 — ToolCallOutputItem.to_input_item has cognitive complexity 26 (threshold 15). Drivers by points: if/else 6 (22 pts), loops 1 (4 pts) (nesting depth added 19). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · Converter.convert_tools (cognitive 26) · ×1
  • Converter.convert_tools (cognitive 26) src/agents/models/openai_responses.py:2115 — Converter.convert_tools has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 3, loops 3, ternaries 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_state._serialize_pending_nested_agent_tool_runs (cognitive 26) · ×1
  • run_state._serialize_pending_nested_agent_tool_runs (cognitive 26) src/agents/run_state.py:2956 — run_state._serialize_pending_nested_agent_tool_runs has cognitive complexity 26 (threshold 15). Drivers by points: if/else 9 (19 pts), error handling 2 (4 pts), boolean chains 2, loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · tool._normalize_function_tool_callable (cognitive 26) · ×1
  • tool._normalize_function_tool_callable (cognitive 26) src/agents/tool.py:2507 — tool._normalize_function_tool_callable has cognitive complexity 26 (threshold 15). Drivers by points: if/else 12, boolean chains 7, ternaries 3 (5 pts), error handling 2 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · StreamedAudioResult._dispatch_audio (cognitive 26) · ×1
  • StreamedAudioResult._dispatch_audio (cognitive 26) src/agents/voice/result.py:335 — StreamedAudioResult._dispatch_audio has cognitive complexity 26 (threshold 15). Drivers by points: if/else 7 (22 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 16). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · visualization._get_all_nodes (cognitive 25) · ×1
  • visualization._get_all_nodes (cognitive 25) src/agents/extensions/visualization.py:194 — visualization._get_all_nodes has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (19 pts), boolean chains 3, loops 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _MCPServerWithClientSession.cleanup (cognitive 25) · ×1
  • _MCPServerWithClientSession.cleanup (cognitive 25) src/agents/mcp/server.py:1831 — _MCPServerWithClientSession.cleanup has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (20 pts), error handling 3, boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · Converter._validate_named_function_tool_choice (cognitive 25) · ×1
  • Converter._validate_named_function_tool_choice (cognitive 25) src/agents/models/openai_responses.py:1939 — Converter._validate_named_function_tool_choice has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 10, loops 2 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunContextWrapper._resolve_call_id (cognitive 25) · ×1
  • RunContextWrapper._resolve_call_id (cognitive 25) src/agents/run_context.py:377 — RunContextWrapper._resolve_call_id has cognitive complexity 25 (threshold 15). Drivers by points: if/else 9 (17 pts), boolean chains 4, ternaries 2 (4 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunContextWrapper._approval_records_for_key (cognitive 25) · ×1
  • RunContextWrapper._approval_records_for_key (cognitive 25) src/agents/run_context.py:436 — RunContextWrapper._approval_records_for_key has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (15 pts), ternaries 3 (7 pts), boolean chains 3 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunContextWrapper._restore_pending_approval_binding (cognitive 25) · ×1
  • RunContextWrapper._restore_pending_approval_binding (cognitive 25) src/agents/run_context.py:770 — RunContextWrapper._restore_pending_approval_binding has cognitive complexity 25 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 9, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunState._serialize_context_payload (cognitive 25) · ×1
  • RunState._serialize_context_payload (cognitive 25) src/agents/run_state.py:1651 — RunState._serialize_context_payload has cognitive complexity 25 (threshold 15). Drivers by points: if/else 11 (14 pts), error handling 4 (10 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · BackendSpanExporter._sanitize_json_compatible_value (cognitive 25) · ×1
  • BackendSpanExporter._sanitize_json_compatible_value (cognitive 25) src/agents/tracing/processors.py:635 — BackendSpanExporter._sanitize_json_compatible_value has cognitive complexity 25 (threshold 15). Drivers by points: if/else 10 (18 pts), loops 2 (4 pts), ternaries 1 (2 pts), boolean chains 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · review_protocol._review_state (cognitive 24) · ×1
  • review_protocol._review_state (cognitive 24) .agents/skills/implementation-final-review/scripts/review_protocol.py:391 — review_protocol._review_state has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (18 pts), loops 3 (4 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · audio_formats.to_realtime_audio_format (cognitive 24) · ×1
  • audio_formats.to_realtime_audio_format (cognitive 24) src/agents/realtime/audio_formats.py:17 — audio_formats.to_realtime_audio_format has cognitive complexity 24 (threshold 15). Drivers by points: if/else 11 (23 pts), boolean chains 1 (nesting depth added 12). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · _FunctionToolBatchExecutor._maybe_execute_tool_approval (cognitive 24) · ×1
  • _FunctionToolBatchExecutor._maybe_execute_tool_approval (cognitive 24) src/agents/run_internal/tool_execution.py:1875 — _FunctionToolBatchExecutor._maybe_execute_tool_approval has cognitive complexity 24 (threshold 15). Drivers by points: if/else 12 (19 pts), boolean chains 5 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ScriptedModel.stream_response (cognitive 24) · ×1
  • ScriptedModel.stream_response (cognitive 24) src/agents/testing/model.py:370 — ScriptedModel.stream_response has cognitive complexity 24 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 4 (8 pts), loops 3 (5 pts) (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · review_state.review_state (cognitive 23) · ×1
  • review_state.review_state (cognitive 23) .agents/skills/implementation-final-review/scripts/review_state.py:491 — review_state.review_state has cognitive complexity 23 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 4, loops 3 (4 pts), error handling 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AdvancedSQLiteSession._extract_tool_name (cognitive 23) · ×1
  • AdvancedSQLiteSession._extract_tool_name (cognitive 23) src/agents/extensions/memory/advanced_sqlite_session.py:996 — AdvancedSQLiteSession._extract_tool_name has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (16 pts), ternaries 1 (4 pts), boolean chains 3 (nesting depth added 13). To reduce it, flatten the nesting: this score is depth rather than breadth — most of its points come from checks stacked inside one another, so the work sits several levels in. Invert each enclosing check into an early exit (a return, or the language's equivalent) so the happy path stays at one level, and where a level cannot be exited early, lift the block it encloses into its own named function.
D2 · Cognitive Complexity · blocked_output._current_response_boundary (cognitive 23) · ×1
  • blocked_output._current_response_boundary (cognitive 23) src/agents/run_internal/blocked_output.py:369 — blocked_output._current_response_boundary has cognitive complexity 23 (threshold 15). Drivers by points: if/else 7 (16 pts), boolean chains 4, ternaries 2, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · guardrails.run_input_guardrails_with_queue (cognitive 23) · ×1
  • guardrails.run_input_guardrails_with_queue (cognitive 23) src/agents/run_internal/guardrails.py:55 — guardrails.run_input_guardrails_with_queue has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (14 pts), loops 3 (6 pts), boolean chains 2, error handling 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · model._convert_output_items (cognitive 23) · ×1
  • model._convert_output_items (cognitive 23) src/agents/testing/model.py:641 — model._convert_output_items has cognitive complexity 23 (threshold 15). Drivers by points: if/else 6 (14 pts), ternaries 2 (6 pts), boolean chains 2, loops 1 (nesting depth added 12). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · apply_diff._advance_cursor_to_anchor (cognitive 22) · ×1
  • apply_diff._advance_cursor_to_anchor (cognitive 22) src/agents/apply_diff.py:207 — apply_diff._advance_cursor_to_anchor has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 2 (5 pts), boolean chains 3 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · codex_tool.codex_tool (cognitive 22) · ×1
  • codex_tool.codex_tool (cognitive 22) src/agents/extensions/experimental/codex/codex_tool.py:237 — codex_tool.codex_tool has cognitive complexity 22 (threshold 15). Drivers by points: if/else 21, boolean chains 1. To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · OpenAIHostedMultiAgentModel._prepare_websocket_request (cognitive 22) · ×1
  • OpenAIHostedMultiAgentModel._prepare_websocket_request (cognitive 22) src/agents/extensions/experimental/hosted_multi_agent/model.py:478 — OpenAIHostedMultiAgentModel._prepare_websocket_request has cognitive complexity 22 (threshold 15). Drivers by points: if/else 10 (17 pts), boolean chains 3, loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DaprSession.get_items (cognitive 22) · ×1
  • DaprSession.get_items (cognitive 22) src/agents/extensions/memory/dapr_session.py:302 — DaprSession.get_items has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (14 pts), error handling 2 (5 pts), loops 2 (3 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AnyLLMModel._get_response_via_chat (cognitive 22) · ×1
  • AnyLLMModel._get_response_via_chat (cognitive 22) src/agents/extensions/models/any_llm_model.py:580 — AnyLLMModel._get_response_via_chat has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8, boolean chains 7, ternaries 5 (7 pts) (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · ItemHelpers.tool_call_output_item (cognitive 22) · ×1
  • ItemHelpers.tool_call_output_item (cognitive 22) src/agents/items.py:845 — ItemHelpers.tool_call_output_item has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (12 pts), error handling 3 (8 pts), ternaries 1 (2 pts) (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · items.resolve_nested_history_owned_item_indexes (cognitive 22) · ×1
  • items.resolve_nested_history_owned_item_indexes (cognitive 22) src/agents/run_internal/items.py:607 — items.resolve_nested_history_owned_item_indexes has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (11 pts), ternaries 3 (6 pts), boolean chains 3, loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _FunctionToolBatchExecutor._invoke_tool_and_run_post_invoke (cognitive 22) · ×1
  • _FunctionToolBatchExecutor._invoke_tool_and_run_post_invoke (cognitive 22) src/agents/run_internal/tool_execution.py:2079 — _FunctionToolBatchExecutor._invoke_tool_and_run_post_invoke has cognitive complexity 22 (threshold 15). Drivers by points: if/else 8 (12 pts), ternaries 5 (6 pts), boolean chains 3, error handling 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _FunctionToolBatchExecutor._await_invoke_task (cognitive 22) · ×1
  • _FunctionToolBatchExecutor._await_invoke_task (cognitive 22) src/agents/run_internal/tool_execution.py:2201 — _FunctionToolBatchExecutor._await_invoke_task has cognitive complexity 22 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 3, ternaries 1 (3 pts), error handling 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · sandbox._normalize_step (cognitive 22) · ×1
  • sandbox._normalize_step (cognitive 22) src/agents/testing/sandbox.py:213 — sandbox._normalize_step has cognitive complexity 22 (threshold 15). Drivers by points: if/else 11, boolean chains 5, ternaries 2 (4 pts), error handling 1 (2 pts) (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · validate_handoff.validate (cognitive 21) · ×1
  • validate_handoff.validate (cognitive 21) .agents/skills/implementation-kickoff/scripts/validate_handoff.py:146 — validate_handoff.validate has cognitive complexity 21 (threshold 15). Drivers by points: if/else 13 (16 pts), boolean chains 2, ternaries 2, loops 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · codex_tool._validate_descriptor (cognitive 21) · ×1
  • codex_tool._validate_descriptor (cognitive 21) src/agents/extensions/experimental/codex/codex_tool.py:727 — codex_tool._validate_descriptor has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 3, loops 2 (3 pts), ternaries 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ToolOutputTrimmer.__call__ (cognitive 21) · ×1
  • ToolOutputTrimmer.__call__ (cognitive 21) src/agents/extensions/tool_output_trimmer.py:136 — ToolOutputTrimmer.__call__ has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 3, ternaries 1 (3 pts), loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _MCPServerWithClientSession.list_prompts (cognitive 21) · ×1
  • _MCPServerWithClientSession.list_prompts (cognitive 21) src/agents/mcp/server.py:1690 — _MCPServerWithClientSession.list_prompts has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (15 pts), boolean chains 3, error handling 1 (2 pts), loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RealtimeSession._maybe_request_tool_approval (cognitive 21) · ×1
  • RealtimeSession._maybe_request_tool_approval (cognitive 21) src/agents/realtime/session.py:704 — RealtimeSession._maybe_request_tool_approval has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (17 pts), boolean chains 4 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunResultStreaming.stream_events (cognitive 21) · ×1
  • RunResultStreaming.stream_events (cognitive 21) src/agents/result.py:1005 — RunResultStreaming.stream_events has cognitive complexity 21 (threshold 15). Drivers by points: if/else 9 (13 pts), boolean chains 5, error handling 1 (2 pts), loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SandboxRunConfig.__post_init__ (cognitive 21) · ×1
  • SandboxRunConfig.__post_init__ (cognitive 21) src/agents/run_config.py:289 — SandboxRunConfig.__post_init__ has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (19 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · session_persistence.resolve_nested_history_owned_session_item_refs (cognitive 21) · ×1
  • session_persistence.resolve_nested_history_owned_session_item_refs (cognitive 21) src/agents/run_internal/session_persistence.py:335 — session_persistence.resolve_nested_history_owned_session_item_refs has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (13 pts), ternaries 2 (4 pts), boolean chains 2, loops 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · session_persistence.defer_interrupted_session_write (cognitive 21) · ×1
  • session_persistence.defer_interrupted_session_write (cognitive 21) src/agents/run_internal/session_persistence.py:1274 — session_persistence.defer_interrupted_session_write has cognitive complexity 21 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 4, ternaries 4, loops 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · tool_execution.execute_approved_tools (cognitive 21) · ×1
  • tool_execution.execute_approved_tools (cognitive 21) src/agents/run_internal/tool_execution.py:2601 — tool_execution.execute_approved_tools has cognitive complexity 21 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 3 (4 pts), boolean chains 3 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunState.add_input (cognitive 21) · ×1
  • RunState.add_input (cognitive 21) src/agents/run_state.py:1059 — RunState.add_input has cognitive complexity 21 (threshold 15). Drivers by points: if/else 8 (13 pts), boolean chains 5, loops 1 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · model._validate_model_step (cognitive 21) · ×1
  • model._validate_model_step (cognitive 21) src/agents/testing/model.py:709 — model._validate_model_step has cognitive complexity 21 (threshold 15). Drivers by points: if/else 11 (12 pts), boolean chains 9 (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · _tool_identity._format_tool_name_collision_message (cognitive 20) · ×1
  • _tool_identity._format_tool_name_collision_message (cognitive 20) src/agents/_tool_identity.py:431 — _tool_identity._format_tool_name_collision_message has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (10 pts), ternaries 3 (7 pts), boolean chains 2, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · exceptions._object_instance_dict (cognitive 20) · ×1
  • exceptions._object_instance_dict (cognitive 20) src/agents/exceptions.py:93 — exceptions._object_instance_dict has cognitive complexity 20 (threshold 15). Drivers by points: if/else 4 (7 pts), error handling 1 (4 pts), ternaries 1 (4 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RedisSession._mutate_items (cognitive 20) · ×1
  • RedisSession._mutate_items (cognitive 20) src/agents/extensions/memory/redis_session.py:604 — RedisSession._mutate_items has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (19 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · SQLAlchemySession._pop_item (cognitive 20) · ×1
  • SQLAlchemySession._pop_item (cognitive 20) src/agents/extensions/memory/sqlalchemy_session.py:612 — SQLAlchemySession._pop_item has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (17 pts), error handling 1 (2 pts), loops 1 (nesting depth added 11). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ToolOutputTrimmer._build_call_id_to_names (cognitive 20) · ×1
  • ToolOutputTrimmer._build_call_id_to_names (cognitive 20) src/agents/extensions/tool_output_trimmer.py:222 — ToolOutputTrimmer._build_call_id_to_names has cognitive complexity 20 (threshold 15). Drivers by points: if/else 5 (14 pts), boolean chains 5, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MCPServer._normalize_needs_approval (cognitive 20) · ×1
  • MCPServer._normalize_needs_approval (cognitive 20) src/agents/mcp/server.py:739 — MCPServer._normalize_needs_approval has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 3 (6 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIChatCompletionsModel._validate_official_openai_input_content_types (cognitive 20) · ×1
  • OpenAIChatCompletionsModel._validate_official_openai_input_content_types (cognitive 20) src/agents/models/openai_chatcompletions.py:182 — OpenAIChatCompletionsModel._validate_official_openai_input_content_types has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (14 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIResponsesWSModel.get_retry_advice (cognitive 20) · ×1
  • OpenAIResponsesWSModel.get_retry_advice (cognitive 20) src/agents/models/openai_responses.py:1186 — OpenAIResponsesWSModel.get_retry_advice has cognitive complexity 20 (threshold 15). Drivers by points: if/else 11 (15 pts), boolean chains 5 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIRealtimeWebSocketModel.close (cognitive 20) · ×1
  • OpenAIRealtimeWebSocketModel.close (cognitive 20) src/agents/realtime/openai_realtime.py:1279 — OpenAIRealtimeWebSocketModel.close has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (12 pts), error handling 4 (8 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · blocked_output._prepare_blocked_output_owner_plan (cognitive 20) · ×1
  • blocked_output._prepare_blocked_output_owner_plan (cognitive 20) src/agents/run_internal/blocked_output.py:731 — blocked_output._prepare_blocked_output_owner_plan has cognitive complexity 20 (threshold 15). Drivers by points: if/else 9 (10 pts), ternaries 4 (7 pts), boolean chains 3 (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · session_persistence.rewind_session_items (cognitive 20) · ×1
  • session_persistence.rewind_session_items (cognitive 20) src/agents/run_internal/session_persistence.py:1622 — session_persistence.rewind_session_items has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 4, loops 2 (3 pts), error handling 2 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · tool_execution.coerce_shell_call (cognitive 20) · ×1
  • tool_execution.coerce_shell_call (cognitive 20) src/agents/run_internal/tool_execution.py:652 — tool_execution.coerce_shell_call has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 4, loops 2, ternaries 1 (nesting depth added 3). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · tool_execution.normalize_shell_output (cognitive 20) · ×1
  • tool_execution.normalize_shell_output (cognitive 20) src/agents/run_internal/tool_execution.py:893 — tool_execution.normalize_shell_output has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (14 pts), boolean chains 4, ternaries 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · turn_resolution._completed_tool_step_items (cognitive 20) · ×1
  • turn_resolution._completed_tool_step_items (cognitive 20) src/agents/run_internal/turn_resolution.py:901 — turn_resolution._completed_tool_step_items has cognitive complexity 20 (threshold 15). Drivers by points: if/else 7 (14 pts), boolean chains 5, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · turn_resolution._collect_program_parent_state (cognitive 20) · ×1
  • turn_resolution._collect_program_parent_state (cognitive 20) src/agents/run_internal/turn_resolution.py:1354 — turn_resolution._collect_program_parent_state has cognitive complexity 20 (threshold 15). Drivers by points: if/else 6 (15 pts), boolean chains 4, loops 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ToolContext._find_nested_approval_target (cognitive 20) · ×1
  • ToolContext._find_nested_approval_target (cognitive 20) src/agents/tool_context.py:127 — ToolContext._find_nested_approval_target has cognitive complexity 20 (threshold 15). Drivers by points: if/else 10 (12 pts), boolean chains 7, loops 1 (nesting depth added 2). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · BackendSpanExporter._sanitize_generation_usage_for_openai_tracing_api (cognitive 20) · ×1
  • BackendSpanExporter._sanitize_generation_usage_for_openai_tracing_api (cognitive 20) src/agents/tracing/processors.py:587 — BackendSpanExporter._sanitize_generation_usage_for_openai_tracing_api has cognitive complexity 20 (threshold 15). Drivers by points: if/else 8 (15 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · review_protocol._workspace_entries (cognitive 19) · ×1
  • review_protocol._workspace_entries (cognitive 19) .agents/skills/implementation-final-review/scripts/review_protocol.py:308 — review_protocol._workspace_entries has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (16 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _tool_identity.get_function_tool_approval_keys (cognitive 19) · ×1
  • _tool_identity.get_function_tool_approval_keys (cognitive 19) src/agents/_tool_identity.py:607 — _tool_identity.get_function_tool_approval_keys has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (12 pts), boolean chains 7 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · events.coerce_thread_event (cognitive 19) · ×1
  • events.coerce_thread_event (cognitive 19) src/agents/extensions/experimental/codex/events.py:111 — events.coerce_thread_event has cognitive complexity 19 (threshold 15). Drivers by points: if/else 10, ternaries 5 (9 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · Thread._run_streamed_internal (cognitive 19) · ×1
  • Thread._run_streamed_internal (cognitive 19) src/agents/extensions/experimental/codex/thread.py:96 — Thread._run_streamed_internal has cognitive complexity 19 (threshold 15). Drivers by points: if/else 5 (9 pts), error handling 3 (6 pts), boolean chains 2, loops 1, ternaries 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AnyLLMModel._sanitize_any_llm_responses_value (cognitive 19) · ×1
  • AnyLLMModel._sanitize_any_llm_responses_value (cognitive 19) src/agents/extensions/models/any_llm_model.py:1448 — AnyLLMModel._sanitize_any_llm_responses_value has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ModelSettings.resolve (cognitive 19) · ×1
  • ModelSettings.resolve (cognitive 19) src/agents/model_settings.py:260 — ModelSettings.resolve has cognitive complexity 19 (threshold 15). Drivers by points: boolean chains 8, if/else 6 (8 pts), ternaries 2 (3 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · result._copy_pending_nested_agent_tool_states (cognitive 19) · ×1
  • result._copy_pending_nested_agent_tool_states (cognitive 19) src/agents/result.py:190 — result._copy_pending_nested_agent_tool_states has cognitive complexity 19 (threshold 15). Drivers by points: if/else 7 (13 pts), ternaries 1 (3 pts), boolean chains 2, loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIServerConversationTracker.mark_input_as_sent (cognitive 19) · ×1
  • OpenAIServerConversationTracker.mark_input_as_sent (cognitive 19) src/agents/run_internal/oai_conversation.py:394 — OpenAIServerConversationTracker.mark_input_as_sent has cognitive complexity 19 (threshold 15). Drivers by points: if/else 8 (15 pts), boolean chains 2, loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · session_persistence.held_session_items_for_save (cognitive 19) · ×1
  • session_persistence.held_session_items_for_save (cognitive 19) src/agents/run_internal/session_persistence.py:1223 — session_persistence.held_session_items_for_save has cognitive complexity 19 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 2, loops 1 (2 pts), ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · tool_execution.execute_computer_actions (cognitive 19) · ×1
  • tool_execution.execute_computer_actions (cognitive 19) src/agents/run_internal/tool_execution.py:2532 — tool_execution.execute_computer_actions has cognitive complexity 19 (threshold 15). Drivers by points: if/else 4 (9 pts), loops 2 (4 pts), ternaries 1 (4 pts), boolean chains 2 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RunState._serialize_item (cognitive 19) · ×1
  • RunState._serialize_item (cognitive 19) src/agents/run_state.py:2172 — RunState._serialize_item has cognitive complexity 19 (threshold 15). Drivers by points: if/else 12, boolean chains 5, error handling 1 (2 pts) (nesting depth added 1). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · run_state._copy_json_compatible_value (cognitive 19) · ×1
  • run_state._copy_json_compatible_value (cognitive 19) src/agents/run_state.py:391 — run_state._copy_json_compatible_value has cognitive complexity 19 (threshold 15). Drivers by points: if/else 11 (16 pts), loops 1 (2 pts), boolean chains 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · tool.maybe_invoke_function_tool_failure_error_function (cognitive 19) · ×1
  • tool.maybe_invoke_function_tool_failure_error_function (cognitive 19) src/agents/tool.py:2094 — tool.maybe_invoke_function_tool_failure_error_function has cognitive complexity 19 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 1 (3 pts), ternaries 1 (3 pts), boolean chains 2 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · model._normalize_response (cognitive 18) · ×1
  • model._normalize_response (cognitive 18) src/agents/extensions/experimental/hosted_multi_agent/model.py:287 — model._normalize_response has cognitive complexity 18 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 3, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DaprSession.pop_item (cognitive 18) · ×1
  • DaprSession.pop_item (cognitive 18) src/agents/extensions/memory/dapr_session.py:449 — DaprSession.pop_item has cognitive complexity 18 (threshold 15). Drivers by points: if/else 3 (9 pts), error handling 2 (5 pts), loops 2 (3 pts), boolean chains 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · LitellmConverter.convert_message_to_openai (cognitive 18) · ×1
  • LitellmConverter.convert_message_to_openai (cognitive 18) src/agents/extensions/models/litellm_model.py:927 — LitellmConverter.convert_message_to_openai has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 2, loops 1 (2 pts), ternaries 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ToolOutputTrimmer._trim_structured_function_call_output (cognitive 18) · ×1
  • ToolOutputTrimmer._trim_structured_function_call_output (cognitive 18) src/agents/extensions/tool_output_trimmer.py:272 — ToolOutputTrimmer._trim_structured_function_call_output has cognitive complexity 18 (threshold 15). Drivers by points: if/else 8 (11 pts), ternaries 3 (5 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ToolApprovalItem.__post_init__ (cognitive 18) · ×1
  • ToolApprovalItem.__post_init__ (cognitive 18) src/agents/items.py:585 — ToolApprovalItem.__post_init__ has cognitive complexity 18 (threshold 15). Drivers by points: if/else 10 (14 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · items.extract_mcp_request_id (cognitive 18) · ×1
  • items.extract_mcp_request_id (cognitive 18) src/agents/run_internal/items.py:944 — items.extract_mcp_request_id has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (10 pts), error handling 3, ternaries 2 (3 pts), boolean chains 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · items.extract_mcp_request_id_from_run (cognitive 18) · ×1
  • items.extract_mcp_request_id_from_run (cognitive 18) src/agents/run_internal/items.py:975 — items.extract_mcp_request_id_from_run has cognitive complexity 18 (threshold 15). Drivers by points: if/else 7 (13 pts), boolean chains 3, error handling 1, ternaries 1 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · session_persistence._held_items_safe_to_settle (cognitive 18) · ×1
  • session_persistence._held_items_safe_to_settle (cognitive 18) src/agents/run_internal/session_persistence.py:1142 — session_persistence._held_items_safe_to_settle has cognitive complexity 18 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 5, loops 3 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · tool_planning._collect_tool_interruptions (cognitive 18) · ×1
  • tool_planning._collect_tool_interruptions (cognitive 18) src/agents/run_internal/tool_planning.py:726 — tool_planning._collect_tool_interruptions has cognitive complexity 18 (threshold 15). Drivers by points: if/else 6 (13 pts), loops 4, boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · strict_schema._json_values_equal (cognitive 18) · ×1
  • strict_schema._json_values_equal (cognitive 18) src/agents/strict_schema.py:510 — strict_schema._json_values_equal has cognitive complexity 18 (threshold 15). Drivers by points: boolean chains 9, if/else 7 (9 pts) (nesting depth added 2). To reduce it, name the conditions: bind each compound test to a well-named local or a small predicate function, so the body reads as a sequence of named decisions rather than a chain of operators.
D2 · Cognitive Complexity · BatchTraceProcessor._export_batches (cognitive 18) · ×1
  • BatchTraceProcessor._export_batches (cognitive 18) src/agents/tracing/processors.py:827 — BatchTraceProcessor._export_batches has cognitive complexity 18 (threshold 15). Drivers by points: if/else 4 (7 pts), error handling 2 (5 pts), boolean chains 3, loops 2 (3 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · validate_handoff.hidden_index_paths (cognitive 17) · ×1
  • validate_handoff.hidden_index_paths (cognitive 17) .agents/skills/implementation-kickoff/scripts/validate_handoff.py:104 — validate_handoff.hidden_index_paths has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (12 pts), boolean chains 3, loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _function_tool_arguments._is_data_only_schema (cognitive 17) · ×1
  • _function_tool_arguments._is_data_only_schema (cognitive 17) src/agents/_function_tool_arguments.py:71 — _function_tool_arguments._is_data_only_schema has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (11 pts), boolean chains 4, error handling 1 (2 pts) (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · agent_tool_input.resolve_agent_tool_input (cognitive 17) · ×1
  • agent_tool_input.resolve_agent_tool_input (cognitive 17) src/agents/agent_tool_input.py:79 — agent_tool_input.resolve_agent_tool_input has cognitive complexity 17 (threshold 15). Drivers by points: if/else 4 (6 pts), ternaries 3 (6 pts), boolean chains 5 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · agent_tool_input._describe_json_schema_field (cognitive 17) · ×1
  • agent_tool_input._describe_json_schema_field (cognitive 17) src/agents/agent_tool_input.py:209 — agent_tool_input._describe_json_schema_field has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (12 pts), ternaries 2 (4 pts), boolean chains 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · codex_tool._validate_run_context_thread_id_context (cognitive 17) · ×1
  • codex_tool._validate_run_context_thread_id_context (cognitive 17) src/agents/extensions/experimental/codex/codex_tool.py:875 — codex_tool._validate_run_context_thread_id_context has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (13 pts), boolean chains 2, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AsyncSQLiteSession.close (cognitive 17) · ×1
  • AsyncSQLiteSession.close (cognitive 17) src/agents/extensions/memory/async_sqlite_session.py:507 — AsyncSQLiteSession.close has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (11 pts), error handling 2 (5 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · visualization._get_all_edges (cognitive 17) · ×1
  • visualization._get_all_edges (cognitive 17) src/agents/extensions/visualization.py:328 — visualization._get_all_edges has cognitive complexity 17 (threshold 15). Drivers by points: if/else 9 (13 pts), loops 3, boolean chains 1 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · handoffs.handoff (cognitive 17) · ×1
  • handoffs.handoff (cognitive 17) src/agents/handoffs/__init__.py:284 — handoffs.handoff has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 3, ternaries 2 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · MCPServerManager._connect_all (cognitive 17) · ×1
  • MCPServerManager._connect_all (cognitive 17) src/agents/mcp/manager.py:387 — MCPServerManager._connect_all has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (14 pts), loops 1 (2 pts), error handling 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAIRealtimeWebSocketModel.connect (cognitive 17) · ×1
  • OpenAIRealtimeWebSocketModel.connect (cognitive 17) src/agents/realtime/openai_realtime.py:594 — OpenAIRealtimeWebSocketModel.connect has cognitive complexity 17 (threshold 15). Drivers by points: if/else 10 (11 pts), error handling 3 (4 pts), boolean chains 2 (nesting depth added 2). To reduce it, split the body: this score is breadth rather than depth — many checks laid out side by side rather than nested inside one another, so inverting conditions into early returns has nothing left to flatten. Group the statements between the checks into named steps and move each step into its own function, so the body reads as a short sequence of named stages.
D2 · Cognitive Complexity · OpenAIRealtimeWebSocketModel._send_interrupt (cognitive 17) · ×1
  • OpenAIRealtimeWebSocketModel._send_interrupt (cognitive 17) src/agents/realtime/openai_realtime.py:1165 — OpenAIRealtimeWebSocketModel._send_interrupt has cognitive complexity 17 (threshold 15). Drivers by points: if/else 8 (10 pts), boolean chains 4, error handling 1 (3 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition.
D2 · Cognitive Complexity · error_handlers.validate_handler_final_output (cognitive 17) · ×1
  • error_handlers.validate_handler_final_output (cognitive 17) src/agents/run_internal/error_handlers.py:170 — error_handlers.validate_handler_final_output has cognitive complexity 17 (threshold 15). Drivers by points: if/else 6 (7 pts), ternaries 2 (4 pts), boolean chains 3, error handling 3 (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · items._drop_reasoning_items_preceding_dropped_calls (cognitive 17) · ×1
  • items._drop_reasoning_items_preceding_dropped_calls (cognitive 17) src/agents/run_internal/items.py:314 — items._drop_reasoning_items_preceding_dropped_calls has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 2 (3 pts), boolean chains 2 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · items.filter_nested_history_owned_item_refs_for_input (cognitive 17) · ×1
  • items.filter_nested_history_owned_item_refs_for_input (cognitive 17) src/agents/run_internal/items.py:455 — items.filter_nested_history_owned_item_refs_for_input has cognitive complexity 17 (threshold 15). Drivers by points: if/else 5 (10 pts), boolean chains 3, loops 2, ternaries 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · tool_execution.render_shell_outputs (cognitive 17) · ×1
  • tool_execution.render_shell_outputs (cognitive 17) src/agents/run_internal/tool_execution.py:975 — tool_execution.render_shell_outputs has cognitive complexity 17 (threshold 15). Drivers by points: if/else 7 (14 pts), ternaries 1 (2 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · input._buffer_to_audio_file (cognitive 17) · ×1
  • input._buffer_to_audio_file (cognitive 17) src/agents/voice/input.py:16 — input._buffer_to_audio_file has cognitive complexity 17 (threshold 15). Drivers by points: if/else 13 (17 pts) (nesting depth added 4). To reduce it, split the body: most of this score is breadth rather than depth — checks laid out side by side rather than stacked — so group the statements between the checks into named steps and move each step into its own function. Some of it IS depth: where a check sits inside another whose only job is to reach it, merge the two into one condition, and where an else follows a branch that already returns, drop the trailing else and let the rest of the body continue at one level.
D2 · Cognitive Complexity · python_probe.summarize_results (cognitive 16) · ×1
  • python_probe.summarize_results (cognitive 16) .agents/skills/runtime-behavior-probe/templates/python_probe.py:139 — python_probe.summarize_results has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (6 pts), ternaries 3 (6 pts), boolean chains 2, loops 2 (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · check_optional_truthiness._walk_scope_bindings (cognitive 16) · ×1
  • check_optional_truthiness._walk_scope_bindings (cognitive 16) .github/scripts/check_optional_truthiness.py:84 — check_optional_truthiness._walk_scope_bindings has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (15 pts), loops 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _config_coercion.coerce_pydantic_config (cognitive 16) · ×1
  • _config_coercion.coerce_pydantic_config (cognitive 16) src/agents/_config_coercion.py:69 — _config_coercion.coerce_pydantic_config has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (14 pts), loops 1 (2 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _tool_invocation.tool_invocation_approval_scope (cognitive 16) · ×1
  • _tool_invocation.tool_invocation_approval_scope (cognitive 16) src/agents/_tool_invocation.py:251 — _tool_invocation.tool_invocation_approval_scope has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (11 pts), boolean chains 3, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · apply_diff._parse_update_diff (cognitive 16) · ×1
  • apply_diff._parse_update_diff (cognitive 16) src/agents/apply_diff.py:126 — apply_diff._parse_update_diff has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (7 pts), loops 3 (5 pts), ternaries 1 (3 pts), boolean chains 1 (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · AsyncSQLiteSession._write_connection (cognitive 16) · ×1
  • AsyncSQLiteSession._write_connection (cognitive 16) src/agents/extensions/memory/async_sqlite_session.py:184 — AsyncSQLiteSession._write_connection has cognitive complexity 16 (threshold 15). Drivers by points: error handling 4 (8 pts), if/else 4 (8 pts) (nesting depth added 8). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · DaprSession.add_items (cognitive 16) · ×1
  • DaprSession.add_items (cognitive 16) src/agents/extensions/memory/dapr_session.py:358 — DaprSession.add_items has cognitive complexity 16 (threshold 15). Drivers by points: if/else 3 (7 pts), error handling 2 (4 pts), loops 2, ternaries 1 (2 pts), boolean chains 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · ItemHelpers._convert_single_tool_output_pydantic_model (cognitive 16) · ×1
  • ItemHelpers._convert_single_tool_output_pydantic_model (cognitive 16) src/agents/items.py:1003 — ItemHelpers._convert_single_tool_output_pydantic_model has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (16 pts) (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · handoffs.realtime_handoff (cognitive 16) · ×1
  • handoffs.realtime_handoff (cognitive 16) src/agents/realtime/handoffs.py:108 — handoffs.realtime_handoff has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), boolean chains 3, ternaries 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RealtimeSession.__aiter__ (cognitive 16) · ×1
  • RealtimeSession.__aiter__ (cognitive 16) src/agents/realtime/session.py:314 — RealtimeSession.__aiter__ has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), boolean chains 3, loops 1 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · RealtimeSession._resolve_tool_dispatch_role (cognitive 16) · ×1
  • RealtimeSession._resolve_tool_dispatch_role (cognitive 16) src/agents/realtime/session.py:1465 — RealtimeSession._resolve_tool_dispatch_role has cognitive complexity 16 (threshold 15). Drivers by points: if/else 6 (7 pts), boolean chains 5, ternaries 2 (4 pts) (nesting depth added 3). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · _asyncio_progress._get_self_progress_deadline_for_future (cognitive 16) · ×1
  • _asyncio_progress._get_self_progress_deadline_for_future (cognitive 16) src/agents/run_internal/_asyncio_progress.py:107 — _asyncio_progress._get_self_progress_deadline_for_future has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (14 pts), ternaries 1 (2 pts) (nesting depth added 6). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · blocked_output._prepare_blocked_output_snapshot (cognitive 16) · ×1
  • blocked_output._prepare_blocked_output_snapshot (cognitive 16) src/agents/run_internal/blocked_output.py:464 — blocked_output._prepare_blocked_output_snapshot has cognitive complexity 16 (threshold 15). Drivers by points: if/else 9 (14 pts), boolean chains 1, loops 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · items.rebase_nested_history_owned_item_refs (cognitive 16) · ×1
  • items.rebase_nested_history_owned_item_refs (cognitive 16) src/agents/run_internal/items.py:673 — items.rebase_nested_history_owned_item_refs has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (8 pts), ternaries 3 (6 pts), loops 2 (nesting depth added 7). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · model_retry._normalize_retry_error (cognitive 16) · ×1
  • model_retry._normalize_retry_error (cognitive 16) src/agents/run_internal/model_retry.py:116 — model_retry._normalize_retry_error has cognitive complexity 16 (threshold 15). Drivers by points: if/else 5 (12 pts), loops 1 (3 pts), boolean chains 1 (nesting depth added 9). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_loop._safe_redacted_persistence_error (cognitive 16) · ×1
  • run_loop._safe_redacted_persistence_error (cognitive 16) src/agents/run_internal/run_loop.py:761 — run_loop._safe_redacted_persistence_error has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (12 pts), loops 3, error handling 1 (nesting depth added 5). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · tool_execution.normalize_shell_output_entries (cognitive 16) · ×1
  • tool_execution.normalize_shell_output_entries (cognitive 16) src/agents/run_internal/tool_execution.py:1048 — tool_execution.normalize_shell_output_entries has cognitive complexity 16 (threshold 15). Drivers by points: if/else 4 (11 pts), ternaries 1 (4 pts), loops 1 (nesting depth added 10). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · run_state._deserialize_processed_response (cognitive 16) · ×1
  • run_state._deserialize_processed_response (cognitive 16) src/agents/run_state.py:3229 — run_state._deserialize_processed_response has cognitive complexity 16 (threshold 15). Drivers by points: if/else 7 (10 pts), boolean chains 2, loops 2, ternaries 1 (2 pts) (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D2 · Cognitive Complexity · OpenAISTTTranscriptionSession._check_errors (cognitive 16) · ×1
  • OpenAISTTTranscriptionSession._check_errors (cognitive 16) src/agents/voice/models/openai_stt.py:459 — OpenAISTTTranscriptionSession._check_errors has cognitive complexity 16 (threshold 15). Drivers by points: if/else 8 (12 pts), boolean chains 4 (nesting depth added 4). To reduce it, split the body into named stages: move each independent step or branch into its own named function so the body reads as a short sequence of named calls rather than one long body.
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D29 · Static Analysis (SAST) · REDACTED · ×1
  • REDACTED
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
D4 · Code Duplication · Near-duplicate member pair (49 shared lines) · ×1
  • Near-duplicate member pair (49 shared lines) src/agents/run_internal/tool_actions.py:482 — src/agents/run_internal/tool_actions.py:482-687 | src/agents/run_internal/tool_actions.py:921-1113 — These two members are variants of one another: 49 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Edited copy of a member (56 corresponding lines) · ×1
  • Edited copy of a member (56 corresponding lines) src/agents/run_context.py:1099 — src/agents/run_context.py:1099-1178 | src/agents/run_context.py:1379-1577 — These two members are one piece of code written twice and then edited apart: 56 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Edited copy of a member (32 corresponding lines) · ×1
  • Edited copy of a member (32 corresponding lines) src/agents/run.py:296 — src/agents/run.py:296-383 | src/agents/run.py:401-486 — These two members are one piece of code written twice and then edited apart: 32 consecutive lines correspond almost exactly, broken only by small local edits. Most of that correspondence is NOT reported as duplicated blocks below — the edits cut it into fragments and only the largest of them clear the block floor, so the rows below understate it. The repair is at the members' grain — factor the shared implementation into one the two call with their differences as parameters or as an injected step, or, where the difference is systematic (an extra return value, one transport against another), generate one from the other. Left alone, the next edit has to be made twice and the two will drift further apart.
D4 · Code Duplication · Duplicated block (71–74 lines × 3) · ×1
  • Duplicated block (71–74 lines × 3) src/agents/mcp/server.py:1989 — src/agents/mcp/server.py:1989-2059 | src/agents/mcp/server.py:2139-2211 | src/agents/mcp/server.py:2317-2390 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (56 lines × 2) · ×1
  • Duplicated block (56 lines × 2) src/agents/run_context.py:1115 — src/agents/run_context.py:1115-1170 | src/agents/run_context.py:1417-1472 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (38–51 lines × 2) · ×1
  • Duplicated block (38–51 lines × 2) src/agents/handoffs/__init__.py:296 — src/agents/handoffs/__init__.py:296-346 | src/agents/realtime/handoffs.py:117-154 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/handoffs/__init__.py:296` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (37 lines × 2) · ×1
  • Duplicated block (37 lines × 2) src/agents/handoffs/__init__.py:348 — src/agents/handoffs/__init__.py:348-384 | src/agents/realtime/handoffs.py:156-192 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (33–34 lines × 2) · ×1
  • Duplicated block (33–34 lines × 2) src/agents/run_internal/oai_conversation.py:279 — src/agents/run_internal/oai_conversation.py:279-312 | src/agents/run_internal/oai_conversation.py:315-347 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (33 lines × 2) · ×1
  • Duplicated block (33 lines × 2) src/agents/run_internal/run_loop.py:2583 — src/agents/run_internal/run_loop.py:2583-2615 | src/agents/run_internal/run_loop.py:3000-3032 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/run_loop.py:2583` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (31 lines × 2) · ×1
  • Duplicated block (31 lines × 2) src/agents/run.py:353 — src/agents/run.py:353-383 | src/agents/run.py:456-486 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run.py:353` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (28–29 lines × 2) · ×1
  • Duplicated block (28–29 lines × 2) src/agents/extensions/models/any_llm_model.py:625 — src/agents/extensions/models/any_llm_model.py:625-652 | src/agents/models/openai_chatcompletions.py:273-301 — before extracting anything, compare `src/agents/extensions/models/any_llm_model.py` and `src/agents/models/openai_chatcompletions.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 117 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (21–28 lines × 2) · ×1
  • Duplicated block (21–28 lines × 2) src/agents/extensions/models/any_llm_model.py:973 — src/agents/extensions/models/any_llm_model.py:973-993 | src/agents/models/openai_chatcompletions.py:754-781 — before extracting anything, compare `src/agents/extensions/models/any_llm_model.py` and `src/agents/models/openai_chatcompletions.py` as WHOLE FILES: this scan already matched 6 separate duplicated blocks between them, totalling at least 117 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. The two sit in different directories, so one cannot simply be deleted in favour of the other while both are reached separately: hoist the shared part into a location both already depend on and have each file call it, and retire whichever file turns out to have no caller of its own left. Extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it. Note first that the copies are not typed on the same thing: `FAKE_RESPONSES_ID` names `...models.fake_id` in one and `.fake_id` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (23–26 lines × 2) · ×1
  • Duplicated block (23–26 lines × 2) src/agents/run_internal/tool_actions.py:842 — src/agents/run_internal/tool_actions.py:842-864 | src/agents/run_internal/tool_actions.py:1086-1111 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/tool_actions.py:842` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (24–25 lines × 2) · ×1
  • Duplicated block (24–25 lines × 2) src/agents/models/chatcmpl_stream_handler.py:874 — src/agents/models/chatcmpl_stream_handler.py:874-898 | src/agents/models/chatcmpl_stream_handler.py:959-982 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/models/chatcmpl_stream_handler.py:874` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (23–24 lines × 2) · ×1
  • Duplicated block (23–24 lines × 2) src/agents/run.py:1802 — src/agents/run.py:1802-1825 | src/agents/run.py:1910-1932 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run.py:1802` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (21–22 lines × 2) · ×1
  • Duplicated block (21–22 lines × 2) src/agents/extensions/models/any_llm_model.py:516 — src/agents/extensions/models/any_llm_model.py:516-536 | src/agents/models/openai_responses.py:749-770 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/models/openai_responses.py:749` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (19–21 lines × 2) · ×1
  • Duplicated block (19–21 lines × 2) src/agents/run.py:1421 — src/agents/run.py:1421-1441 | src/agents/run.py:2162-2180 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/agents/run.py:1420` calls `discard_held_current_response` and `src/agents/run.py:2161` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (20–21 lines × 2) · ×1
  • Duplicated block (20–21 lines × 2) src/agents/run_internal/run_loop.py:1861 — src/agents/run_internal/run_loop.py:1861-1880 | src/agents/run_internal/run_loop.py:1952-1972 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/run_loop.py:1952` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (19–20 lines × 2) · ×1
  • Duplicated block (19–20 lines × 2) src/agents/run_internal/turn_resolution.py:3723 — src/agents/run_internal/turn_resolution.py:3723-3742 | src/agents/run_internal/turn_resolution.py:3771-3789 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/turn_resolution.py:3723` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (17–19 lines × 2) · ×1
  • Duplicated block (17–19 lines × 2) src/agents/run.py:1521 — src/agents/run.py:1521-1539 | src/agents/run.py:1686-1702 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run.py:1521` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16–18 lines × 3) · ×1
  • Duplicated block (16–18 lines × 3) src/agents/run_internal/tool_actions.py:670 — src/agents/run_internal/tool_actions.py:670-687 | src/agents/run_internal/tool_actions.py:851-866 | src/agents/run_internal/tool_actions.py:1096-1113 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/tool_actions.py:670` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13–18 lines × 2) · ×1
  • Duplicated block (13–18 lines × 2) src/agents/extensions/models/any_llm_model.py:1584 — src/agents/extensions/models/any_llm_model.py:1584-1596 | src/agents/extensions/models/litellm_model.py:849-866 — before extracting anything, compare `src/agents/extensions/models/any_llm_model.py` and `src/agents/extensions/models/litellm_model.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on.
D4 · Code Duplication · Duplicated block (15–18 lines × 2) · ×1
  • Duplicated block (15–18 lines × 2) src/agents/run_internal/run_loop.py:2559 — src/agents/run_internal/run_loop.py:2559-2576 | src/agents/run_internal/run_loop.py:2986-3000 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/run_internal/run_loop.py:2559` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (16–17 lines × 3) · ×1
  • Duplicated block (16–17 lines × 3) src/agents/models/chatcmpl_stream_handler.py:882 — src/agents/models/chatcmpl_stream_handler.py:882-898 | src/agents/models/chatcmpl_stream_handler.py:966-982 | src/agents/models/chatcmpl_stream_handler.py:1161-1176 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/models/chatcmpl_stream_handler.py:882` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (15–16 lines × 2) · ×1
  • Duplicated block (15–16 lines × 2) src/agents/extensions/models/any_llm_model.py:493 — src/agents/extensions/models/any_llm_model.py:493-507 | src/agents/models/openai_responses.py:712-727 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/models/any_llm_model.py:493` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (14–16 lines × 2) · ×1
  • Duplicated block (14–16 lines × 2) src/agents/extensions/models/any_llm_model.py:1556 — src/agents/extensions/models/any_llm_model.py:1556-1569 | src/agents/extensions/models/litellm_model.py:814-829 — before extracting anything, compare `src/agents/extensions/models/any_llm_model.py` and `src/agents/extensions/models/litellm_model.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (11–15 lines × 3) · ×1
  • Duplicated block (11–15 lines × 3) src/agents/extensions/models/any_llm_model.py:877 — src/agents/extensions/models/any_llm_model.py:877-887 | src/agents/extensions/models/litellm_model.py:552-566 | src/agents/models/openai_chatcompletions.py:636-650 — before extracting anything, compare `src/agents/extensions/models/any_llm_model.py` and `src/agents/extensions/models/litellm_model.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/models/litellm_model.py:552` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note first that the copies are not typed on the same thing: `Converter` names `...models.chatcmpl_converter` in one and `.chatcmpl_converter` in another — different types that share a simple name, which is why the text matched. A single extracted unit cannot be given a parameter type that fits both, so unifying those types (or introducing a shared abstraction over them) is the step that has to come BEFORE the extraction above; if they are deliberately separate, the duplication is the price of that separation and the honest resolution is to record the decision rather than to extract.
D4 · Code Duplication · Duplicated block (13–15 lines × 2) · ×1
  • Duplicated block (13–15 lines × 2) src/agents/run_internal/items.py:472 — src/agents/run_internal/items.py:472-484 | src/agents/run_internal/items.py:548-562 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (13 lines × 3) · ×1
  • Duplicated block (13 lines × 3) src/agents/extensions/models/any_llm_model.py:626 — src/agents/extensions/models/any_llm_model.py:626-638 | src/agents/extensions/models/litellm_model.py:264-276 | src/agents/models/openai_chatcompletions.py:274-286 — before extracting anything, compare `src/agents/extensions/models/any_llm_model.py` and `src/agents/extensions/models/litellm_model.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/agents/extensions/models/litellm_model.py:278` calls `hasattr` and `src/agents/extensions/models/any_llm_model.py:640` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (11–12 lines × 2) · ×1
  • Duplicated block (11–12 lines × 2) src/agents/run_internal/run_loop.py:1339 — src/agents/run_internal/run_loop.py:1339-1349 | src/agents/run_internal/run_loop.py:2409-2420 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (9–11 lines × 3) · ×1
  • Duplicated block (9–11 lines × 3) src/agents/run_internal/oai_conversation.py:233 — src/agents/run_internal/oai_conversation.py:233-243 | src/agents/run_internal/oai_conversation.py:250-258 | src/agents/run_internal/oai_conversation.py:360-370 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited.
D4 · Code Duplication · Duplicated block (6 lines × 3) · ×1
  • Duplicated block (6 lines × 3) src/agents/handoffs/history.py:289 — src/agents/handoffs/history.py:289-294 | src/agents/run_internal/session_persistence.py:347-352 | src/agents/run_state.py:1581-1586 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times.
D4 · Code Duplication · Duplicated block (10 lines × 4) · ×1
  • Duplicated block (10 lines × 4) src/agents/extensions/models/any_llm_model.py:1306 — src/agents/extensions/models/any_llm_model.py:1306-1315 | src/agents/extensions/models/litellm_model.py:878-887 | src/agents/models/openai_chatcompletions.py:134-143 | src/agents/models/openai_responses.py:542-551 — before extracting anything, compare `src/agents/extensions/models/any_llm_model.py` and `src/agents/extensions/models/litellm_model.py` as WHOLE FILES: this scan already matched 8 separate duplicated blocks between them, totalling at least 108 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Near-duplicate member pair (58 shared lines) · ×1
  • Near-duplicate member pair (58 shared lines) src/agents/extensions/sandbox/daytona/sandbox.py:1081 — src/agents/extensions/sandbox/daytona/sandbox.py:1081-1157 | src/agents/extensions/sandbox/e2b/sandbox.py:1488-1560 — These two members are variants of one another: 58 of their lines are already reported as duplicated blocks below, spread through both bodies rather than gathered into one. Read them as a single construct written twice. The repair is at the members' grain — factor the shared pipeline into one implementation the two call with their differences as parameters or as an injected step, or, where the difference is systematic (sync against async, one transport against another), generate one from the other. Extracting the individual blocks below is not the same fix: it leaves the two bodies in place and the next edit still has to be made twice.
D4 · Code Duplication · Members sharing a duplicated core (14 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (14 members, 50+ identical tokens) examples/sandbox/basic.py:167 — examples/sandbox/basic.py:167-221 | examples/sandbox/docker/docker_runner.py:69-157 | examples/sandbox/extensions/blaxel_runner.py:145-233 | examples/sandbox/extensions/blaxel_runner.py:250-327 | examples/sandbox/extensions/blaxel_runner.py:348-420 | examples/sandbox/extensions/cloudflare_runner.py:217-296 | examples/sandbox/extensions/cloudflare_runner.py:317-370 | examples/sandbox/extensions/daytona/daytona_runner.py:103-155 | examples/sandbox/extensions/e2b_runner.py:151-224 | examples/sandbox/extensions/modal_runner.py:261-319 | REDACTED:310-388 | examples/sandbox/tax_prep.py:142-171 | examples/sandbox/unix_local_pty.py:88-151 | examples/sandbox/unix_local_runner.py:139-199 — These 14 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 14 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 14 times.
D4 · Code Duplication · Members sharing a duplicated core (7 members, 50+ identical tokens) · ×1
  • Members sharing a duplicated core (7 members, 50+ identical tokens) src/agents/extensions/sandbox/blaxel/sandbox.py:811 — src/agents/extensions/sandbox/blaxel/sandbox.py:811-898 | src/agents/extensions/sandbox/cloudflare/sandbox.py:1120-1220 | src/agents/extensions/sandbox/daytona/sandbox.py:642-771 | src/agents/extensions/sandbox/e2b/sandbox.py:967-1066 | src/agents/extensions/sandbox/modal/sandbox.py:858-928 | src/agents/sandbox/sandboxes/docker.py:1053-1176 | src/agents/sandbox/sandboxes/unix_local.py:437-530 — These 7 members share a duplicated core: a run of at least 50 identical tokens appears in every one of them. That run is NOT broken out as duplicated-block rows below — it is what admitted this row, and the blocks below cover only the part of it that clears the block floor, so they understate the correspondence. Read the members as one construct written 7 times. The repair is at the members' grain — factor the shared implementation out once and have all of them call it with their differences as parameters or as an injected step, or, where the difference is systematic, generate them from one template. Extracting the individual blocks below is not the same fix: it leaves every body in place and the next edit still has to be made 7 times.
D4 · Code Duplication · Duplicated block (69 lines × 2) · ×1
  • Duplicated block (69 lines × 2) examples/basic/retry.py:22 — examples/basic/retry.py:22-90 | examples/basic/retry_litellm.py:22-90 — before extracting anything, compare `examples/basic/retry.py` and `examples/basic/retry_litellm.py` as WHOLE FILES: 100% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 1 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/basic/retry.py:22` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (51–53 lines × 2) · ×1
  • Duplicated block (51–53 lines × 2) examples/tools/container_shell_inline_skill.py:56 — examples/tools/container_shell_inline_skill.py:56-106 | examples/tools/container_shell_skill_reference.py:49-101 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `examples/tools/container_shell_skill_reference.py:49` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (47–49 lines × 3) · ×1
  • Duplicated block (47–49 lines × 3) examples/sandbox/extensions/blaxel_runner.py:186 — examples/sandbox/extensions/blaxel_runner.py:186-232 | examples/sandbox/extensions/cloudflare_runner.py:247-295 | examples/sandbox/unix_local_pty.py:102-150 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. Read the line range as the matched WINDOW rather than a finished unit: at `examples/sandbox/extensions/cloudflare_runner.py:247` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (46–48 lines × 2) · ×1
  • Duplicated block (46–48 lines × 2) examples/memory/compaction_session_example.py:30 — examples/memory/compaction_session_example.py:30-77 | examples/memory/compaction_session_stateless_example.py:31-76 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from both call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `examples/memory/compaction_session_example.py:30` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/memory/compaction_session_stateless_example.py:30` calls `ModelSettings` and `examples/memory/compaction_session_example.py:29` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (48 lines × 2) · ×1
  • Duplicated block (48 lines × 2) examples/memory/memory_session_hitl_example.py:75 — examples/memory/memory_session_hitl_example.py:75-122 | examples/memory/openai_session_hitl_example.py:73-120 — before extracting anything, compare `examples/memory/memory_session_hitl_example.py` and `examples/memory/openai_session_hitl_example.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 79 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (38–40 lines × 6) · ×1
  • Duplicated block (38–40 lines × 6) examples/memory/dapr_session_example.py:157 — examples/memory/dapr_session_example.py:157-196 | examples/memory/encrypted_session_example.py:41-80 | examples/memory/openai_session_example.py:23-60 | examples/memory/redis_session_example.py:52-89 | examples/memory/sqlalchemy_session_example.py:21-60 | examples/memory/sqlite_session_example.py:24-61 — before extracting anything, compare `examples/memory/dapr_session_example.py` and `examples/memory/redis_session_example.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. Read the line range as the matched WINDOW rather than a finished unit: at `examples/memory/encrypted_session_example.py:41` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/memory/dapr_session_example.py:197` calls `get_items` and `examples/memory/encrypted_session_example.py:81` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (31–33 lines × 2) · ×1
  • Duplicated block (31–33 lines × 2) src/agents/extensions/sandbox/cloudflare/sandbox.py:519 — src/agents/extensions/sandbox/cloudflare/sandbox.py:519-551 | src/agents/extensions/sandbox/cloudflare/sandbox.py:561-591 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (28 lines × 2) · ×1
  • Duplicated block (28 lines × 2) examples/handoffs/message_filter.py:75 — examples/handoffs/message_filter.py:75-102 | examples/handoffs/message_filter_streaming.py:75-102 — before extracting anything, compare `examples/handoffs/message_filter.py` and `examples/handoffs/message_filter_streaming.py` as WHOLE FILES: 92% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place.
D4 · Code Duplication · Duplicated block (27–28 lines × 2) · ×1
  • Duplicated block (27–28 lines × 2) examples/sandbox/tax_prep.py:107 — examples/sandbox/tax_prep.py:107-133 | examples/sandbox/tutorials/vision_website_clone/main.py:123-150 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (24–27 lines × 2) · ×1
  • Duplicated block (24–27 lines × 2) src/agents/extensions/sandbox/blaxel/mounts.py:535 — src/agents/extensions/sandbox/blaxel/mounts.py:535-561 | src/agents/sandbox/entries/mounts/base.py:396-419 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice.
D4 · Code Duplication · Duplicated block (16–25 lines × 3) · ×1
  • Duplicated block (16–25 lines × 3) examples/memory/advanced_sqlite_session_example.py:260 — examples/memory/advanced_sqlite_session_example.py:260-275 | examples/memory/dapr_session_example.py:316-340 | examples/memory/dapr_session_example.py:360-380 — there are 3 copies across 2 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 3 sites; resolving a subset leaves the remainder to drift apart. Read the line range as the matched WINDOW rather than a finished unit: at `examples/memory/dapr_session_example.py:360` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (25 lines × 2) · ×1
  • Duplicated block (25 lines × 2) examples/handoffs/message_filter.py:25 — examples/handoffs/message_filter.py:25-49 | examples/handoffs/message_filter_streaming.py:25-49 — before extracting anything, compare `examples/handoffs/message_filter.py` and `examples/handoffs/message_filter_streaming.py` as WHOLE FILES: 92% of the shorter file's lines also appear in the other, so this reads as one file having been copied from the other rather than as a helper waiting to be extracted. The 2 duplicated block(s) this scan matched between them are fragments of that copy, not the extent of it — treat the file pair as the unit. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (22 lines × 7) · ×1
  • Duplicated block (22 lines × 7) src/agents/extensions/sandbox/blaxel/sandbox.py:877 — src/agents/extensions/sandbox/blaxel/sandbox.py:877-898 | src/agents/extensions/sandbox/cloudflare/sandbox.py:1199-1220 | src/agents/extensions/sandbox/daytona/sandbox.py:750-771 | src/agents/extensions/sandbox/e2b/sandbox.py:1045-1066 | src/agents/extensions/sandbox/modal/sandbox.py:907-928 | src/agents/sandbox/sandboxes/docker.py:1155-1176 | src/agents/sandbox/sandboxes/unix_local.py:509-530 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 7 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 7 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (13–20 lines × 2) · ×1
  • Duplicated block (13–20 lines × 2) examples/financial_research_agent/manager.py:209 — examples/financial_research_agent/manager.py:209-221 | examples/research_bot/manager.py:111-130 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `examples/research_bot/manager.py:111` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (18 lines × 6) · ×1
  • Duplicated block (18 lines × 6) src/agents/extensions/sandbox/blaxel/sandbox.py:919 — src/agents/extensions/sandbox/blaxel/sandbox.py:919-936 | src/agents/extensions/sandbox/daytona/sandbox.py:840-857 | src/agents/extensions/sandbox/e2b/sandbox.py:1090-1107 | src/agents/extensions/sandbox/modal/sandbox.py:948-965 | src/agents/sandbox/sandboxes/docker.py:1209-1226 | src/agents/sandbox/sandboxes/unix_local.py:559-576 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (17–18 lines × 2) · ×1
  • Duplicated block (17–18 lines × 2) examples/memory/file_hitl_example.py:70 — examples/memory/file_hitl_example.py:70-86 | examples/memory/file_hitl_example.py:101-118 — both copies are in the same file, so extract the block into one function there and call it from each site — the copies drift apart the first time only one of them is edited.
D4 · Code Duplication · Duplicated block (10–17 lines × 2) · ×1
  • Duplicated block (10–17 lines × 2) src/agents/extensions/sandbox/cloudflare/sandbox.py:1494 — src/agents/extensions/sandbox/cloudflare/sandbox.py:1494-1503 | src/agents/extensions/sandbox/modal/sandbox.py:2044-2060 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/sandbox/cloudflare/sandbox.py:1494` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `src/agents/extensions/sandbox/modal/sandbox.py:2061` calls `ephemeral_persistence_paths` and `src/agents/extensions/sandbox/cloudflare/sandbox.py:1504` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (16 lines × 3) · ×1
  • Duplicated block (16 lines × 3) src/agents/extensions/sandbox/blaxel/sandbox.py:678 — src/agents/extensions/sandbox/blaxel/sandbox.py:678-693 | src/agents/extensions/sandbox/daytona/sandbox.py:1095-1110 | src/agents/extensions/sandbox/e2b/sandbox.py:1499-1514 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (13–15 lines × 3) · ×1
  • Duplicated block (13–15 lines × 3) src/agents/sandbox/sandboxes/unix_local.py:1029 — src/agents/sandbox/sandboxes/unix_local.py:1029-1041 | src/agents/sandbox/sandboxes/unix_local.py:1195-1209 | src/agents/sandbox/sandboxes/unix_local.py:1239-1252 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/sandbox/sandboxes/unix_local.py:1195` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The `return` at the foot of the matched lines is the enclosing body's own terminal exit, not an early one: it moves with them unchanged, and each site calls the extracted unit from the position that `return` occupied — no decision has to be handed back and re-acted on. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately.
D4 · Code Duplication · Duplicated block (14–15 lines × 2) · ×1
  • Duplicated block (14–15 lines × 2) examples/sandbox/extensions/e2b_runner.py:117 — examples/sandbox/extensions/e2b_runner.py:117-131 | examples/sandbox/sandbox_agent_with_remote_snapshot.py:131-144 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere both call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made twice. Read the line range as the matched WINDOW rather than a finished unit: at `examples/sandbox/extensions/e2b_runner.py:117` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (11–14 lines × 6) · ×1
  • Duplicated block (11–14 lines × 6) examples/sandbox/extensions/blaxel_runner.py:405 — examples/sandbox/extensions/blaxel_runner.py:405-415 | examples/sandbox/extensions/cloudflare_runner.py:355-365 | examples/sandbox/extensions/daytona/daytona_runner.py:136-148 | examples/sandbox/extensions/modal_runner.py:304-314 | REDACTED:369-381 | examples/sandbox/unix_local_runner.py:181-194 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 6 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 6 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (13–14 lines × 4) · ×1
  • Duplicated block (13–14 lines × 4) src/agents/extensions/sandbox/e2b/sandbox.py:1276 — src/agents/extensions/sandbox/e2b/sandbox.py:1276-1289 | src/agents/extensions/sandbox/modal/sandbox.py:1173-1185 | src/agents/sandbox/sandboxes/docker.py:1352-1365 | src/agents/sandbox/sandboxes/unix_local.py:674-687 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/sandbox/e2b/sandbox.py:1276` it does not close everything it opens, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (13–14 lines × 3) · ×1
  • Duplicated block (13–14 lines × 3) examples/sandbox/extensions/cloudflare_runner.py:162 — examples/sandbox/extensions/cloudflare_runner.py:162-174 | examples/sandbox/extensions/modal_runner.py:180-193 | REDACTED:149-162 — the copies sit in sibling files of one directory, so a shared home is within easy reach: extract the block into a single shared function the call sites can all reach — a file they already depend on, or a new one alongside them — and call it from all 3 call sites, so a change lands once. Read the line range as the matched WINDOW rather than a finished unit: at `examples/sandbox/extensions/modal_runner.py:180` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that.
D4 · Code Duplication · Duplicated block (13 lines × 5) · ×1
  • Duplicated block (13 lines × 5) src/agents/extensions/sandbox/cloudflare/sandbox.py:1059 — src/agents/extensions/sandbox/cloudflare/sandbox.py:1059-1071 | src/agents/extensions/sandbox/e2b/sandbox.py:1279-1291 | src/agents/extensions/sandbox/modal/sandbox.py:1175-1187 | src/agents/sandbox/sandboxes/docker.py:1355-1367 | src/agents/sandbox/sandboxes/unix_local.py:677-689 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (12 lines × 5) · ×1
  • Duplicated block (12 lines × 5) examples/sandbox/basic.py:196 — examples/sandbox/basic.py:196-207 | examples/sandbox/docker/docker_runner.py:127-138 | examples/sandbox/extensions/blaxel_runner.py:191-202 | examples/sandbox/extensions/cloudflare_runner.py:254-265 | examples/sandbox/unix_local_pty.py:109-120 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (7–9 lines × 8) · ×1
  • Duplicated block (7–9 lines × 8) examples/sandbox/extensions/blaxel_runner.py:314 — examples/sandbox/extensions/blaxel_runner.py:314-322 | examples/sandbox/extensions/blaxel_runner.py:410-416 | examples/sandbox/extensions/cloudflare_runner.py:360-366 | examples/sandbox/extensions/daytona/daytona_runner.py:141-149 | examples/sandbox/extensions/modal_runner.py:309-315 | REDACTED:374-382 | examples/sandbox/tax_prep.py:142-148 | examples/sandbox/unix_local_runner.py:187-195 — there are 8 copies across 7 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 8 sites; resolving a subset leaves the remainder to drift apart.
D4 · Code Duplication · Duplicated block (9 lines × 4) · ×1
  • Duplicated block (9 lines × 4) src/agents/extensions/sandbox/cloudflare/sandbox.py:1078 — src/agents/extensions/sandbox/cloudflare/sandbox.py:1078-1086 | src/agents/extensions/sandbox/e2b/sandbox.py:1298-1306 | src/agents/sandbox/sandboxes/docker.py:1374-1382 | src/agents/sandbox/sandboxes/unix_local.py:696-704 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 4 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 4 times. Read the line range as the matched WINDOW rather than a finished unit: at `src/agents/extensions/sandbox/cloudflare/sandbox.py:1078` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (8–9 lines × 3) · ×1
  • Duplicated block (8–9 lines × 3) src/agents/extensions/sandbox/blaxel/sandbox.py:564 — src/agents/extensions/sandbox/blaxel/sandbox.py:564-571 | src/agents/extensions/sandbox/daytona/sandbox.py:1001-1008 | src/agents/extensions/sandbox/e2b/sandbox.py:1166-1174 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/agents/extensions/sandbox/blaxel/sandbox.py:560` calls `posix_path_as_path`, `coerce_posix_path` and `src/agents/extensions/sandbox/e2b/sandbox.py:1162` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (6–8 lines × 14) · ×1
  • Duplicated block (6–8 lines × 14) examples/sandbox/basic.py:195 — examples/sandbox/basic.py:195-202 | examples/sandbox/docker/docker_runner.py:126-133 | examples/sandbox/extensions/blaxel_runner.py:190-197 | examples/sandbox/extensions/blaxel_runner.py:316-323 | examples/sandbox/extensions/blaxel_runner.py:412-417 | examples/sandbox/extensions/cloudflare_runner.py:253-260 | examples/sandbox/extensions/cloudflare_runner.py:362-367 | examples/sandbox/extensions/daytona/daytona_runner.py:143-150 | examples/sandbox/extensions/e2b_runner.py:211-218 | examples/sandbox/extensions/modal_runner.py:311-316 | REDACTED:376-383 | examples/sandbox/tax_prep.py:144-149 | examples/sandbox/unix_local_pty.py:108-115 | examples/sandbox/unix_local_runner.py:189-196 — there are 14 copies across 11 file(s) — more copies than files, so at least one file holds the block twice. Extract it once into a single shared function every call site can reach and call it from all 14 sites; resolving a subset leaves the remainder to drift apart. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just after the matched lines, `examples/sandbox/extensions/e2b_runner.py:220` calls `_rewrite_template_resolution_error` and `examples/sandbox/extensions/blaxel_runner.py:324` does not — after which the two agree again for 2 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7–8 lines × 6) · ×1
  • Duplicated block (7–8 lines × 6) examples/memory/dapr_session_example.py:201 — examples/memory/dapr_session_example.py:201-207 | examples/memory/encrypted_session_example.py:80-86 | examples/memory/openai_session_example.py:60-67 | examples/memory/redis_session_example.py:94-100 | examples/memory/sqlalchemy_session_example.py:60-66 | examples/memory/sqlite_session_example.py:61-67 — before extracting anything, compare `examples/memory/dapr_session_example.py` and `examples/memory/redis_session_example.py` as WHOLE FILES: this scan already matched 3 separate duplicated blocks between them, totalling at least 65 lines, which is the signature of one file having been copied from the other rather than of a helper waiting to be extracted. If that is what happened, the fix is to keep one copy and have the other call it (or delete it), which resolves this row and its siblings together — extracting one helper per block leaves the fork in place. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/memory/redis_session_example.py:90` calls `get_items` and `examples/memory/encrypted_session_example.py:77` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (4–8 lines × 3) · ×1
  • Duplicated block (4–8 lines × 3) examples/memory/advanced_sqlite_session_example.py:145 — examples/memory/advanced_sqlite_session_example.py:145-152 | examples/memory/advanced_sqlite_session_example.py:173-176 | examples/memory/advanced_sqlite_session_example.py:211-218 — all 3 copies are in the same file, so extract the block into one function there and call it from every one of those sites — resolving only two of them leaves the rest to drift apart the first time one is edited. Read the line range as the matched WINDOW rather than a finished unit: at `examples/memory/advanced_sqlite_session_example.py:145` it begins part-way through the construct above it, so those exact lines cannot be lifted as they stand — widen the region to the smallest complete statement or declaration that contains it, and extract that. Note that the copies do not run to the end of the range shown: their LAST lines are different code, not the same code under different names — the matched region ends inside that line. Extract the lines above it, and read the last line of each site separately. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `examples/memory/advanced_sqlite_session_example.py:209` calls `get`, `str` and `examples/memory/advanced_sqlite_session_example.py:173` does not — after which the two agree again for 3 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7 lines × 3) · ×1
  • Duplicated block (7 lines × 3) examples/mcp/prompt_server/main.py:17 — examples/mcp/prompt_server/main.py:17-23 | examples/mcp/streamablehttp_custom_client_example/main.py:25-31 | examples/mcp/streamablehttp_example/main.py:17-23 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. The matched lines also transfer control out of the body holding them, which cannot survive a move into a called unit unchanged: have the extracted unit return that decision and let each site act on it.
D4 · Code Duplication · Duplicated block (6–7 lines × 3) · ×1
  • Duplicated block (6–7 lines × 3) src/agents/extensions/sandbox/blaxel/sandbox.py:744 — src/agents/extensions/sandbox/blaxel/sandbox.py:744-749 | src/agents/extensions/sandbox/daytona/sandbox.py:1161-1166 | src/agents/extensions/sandbox/e2b/sandbox.py:1565-1571 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 3 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 3 times. ★ These copies have DRIFTED, and that is worth reading before extracting anything: just before the matched lines, `src/agents/extensions/sandbox/e2b/sandbox.py:1564` calls `posix_path_for_error` and `src/agents/extensions/sandbox/blaxel/sandbox.py:743` does not — after which the two agree again for 4 more lines. One of those two behaviours is the intended one and the other is what a copy-paste left behind, so decide which BEFORE unifying them: extracting the shared part will silently settle it, and if the copy that skips the call is the wrong one, that bug is already live.
D4 · Code Duplication · Duplicated block (7 lines × 5) · ×1
  • Duplicated block (7 lines × 5) src/agents/extensions/sandbox/cloudflare/sandbox.py:1261 — src/agents/extensions/sandbox/cloudflare/sandbox.py:1261-1267 | src/agents/extensions/sandbox/e2b/sandbox.py:1110-1116 | src/agents/extensions/sandbox/modal/sandbox.py:968-974 | src/agents/sandbox/sandboxes/docker.py:1229-1235 | src/agents/sandbox/sandboxes/unix_local.py:579-585 — the copies span different directories, so extracting a shared function means choosing where it lives: put it somewhere all 5 call sites can already reach — a location they all depend on today, or a new shared one if there is none — and call it from each site; until then, every change has to be made 5 times.
D6 · Cohesion (LCOM4) · Low cohesion · ×1
  • Low cohesion: BaseSandboxSession (LCOM4 4) src/agents/sandbox/session/base_sandbox_session.py:200 — BaseSandboxSession's methods fall into 4 groups that share no field and call none of each other, against a bar of more than 3 for this run (LCOM4, configurable — your repository's bar is the one quoted here). Each group is a set of methods reachable from one another through shared fields or direct calls, so 4 groups means the type has that many internally-connected clusters with nothing tying them together. Types whose shape makes a high count expected — and which would otherwise dominate this list — are excluded before this row is raised, so this is a genuine split candidate rather than a metric reading. It is still a shape, not a defect: confirm the groups match responsibilities you can name before splitting.
Minor — 58 finding(s)
X10 · Duplicated predicate · Duplicated predicate · ×25
  • Duplicated predicate src/agents/logger.py:204 — `_debug.DONT_LOG_MODEL_DATA or _debug.DONT_LOG_TOOL_DATA` appears character-identically in 6 files — src/agents/logger.py, REDACTED, src/agents/run_internal/session_persistence.py, src/agents/tracing/processors.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/realtime/session.py:739 — `approval_status is None and evaluation.outcome == "invoke"` appears character-identically in 2 files — src/agents/realtime/session.py, src/agents/run_internal/tool_execution.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/run_context.py:1205 — `call_identity is not None and call_identity[1] is None` appears character-identically in 2 files — src/agents/run_context.py, src/agents/run_internal/tool_planning.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/run_internal/tool_planning.py:464 — `call_identity is not None and call_identity[1] is not None` appears character-identically in 2 files — src/agents/run_internal/tool_planning.py, src/agents/run_state.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate .agents/skills/implementation-final-review/scripts/review_state.py:80 — `candidate.exists() or candidate.is_symlink()` appears character-identically in 2 files — .agents/skills/implementation-final-review/scripts/review_state.py, .agents/skills/implementation-kickoff/scripts/validate_handoff.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate REDACTED:839 — `context.run_config is None or context.run_config.trace_include_sensitive_data` appears character-identically in 2 files — REDACTED, src/agents/tool.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/run.py:714 — `conversation_id is not None or previous_response_id is not None or auto_previous_response_id` appears character-identically in 2 files — src/agents/run.py, src/agents/run_internal/run_loop.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/models/_retry_runtime.py:19 — `current is not None and id(current) not in seen` appears character-identically in 2 files — src/agents/models/_retry_runtime.py, src/agents/models/openai_responses.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/models/_retry_runtime.py:22 — `current.__cause__ or current.__context__` appears character-identically in 3 files — src/agents/models/_retry_runtime.py, src/agents/models/openai_responses.py, src/agents/tool.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/extensions/memory/async_sqlite_session.py:414 — `expired_end != prefix[-1][0] or len(prefix) < limit` appears character-identically in 2 files — src/agents/extensions/memory/async_sqlite_session.py, src/agents/memory/sqlite_session.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/extensions/experimental/hosted_multi_agent/model.py:516 — `extra_body is not None and not _is_openai_omitted_value(extra_body)` appears character-identically in 2 files — src/agents/extensions/experimental/hosted_multi_agent/model.py, src/agents/models/openai_responses.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/extensions/experimental/hosted_multi_agent/model.py:507 — `extra_query is not None and not _is_openai_omitted_value(extra_query)` appears character-identically in 2 files — src/agents/extensions/experimental/hosted_multi_agent/model.py, src/agents/models/_openai_websocket.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/extensions/models/any_llm_model.py:695 — `first_choice is not None and first_choice.logprobs is not None and first_choice.logprobs.content` appears character-identically in 2 files — src/agents/extensions/models/any_llm_model.py, src/agents/models/openai_chatcompletions.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/run_internal/agent_runner_helpers.py:212 — `getattr(raw, "call_id", None) or getattr(raw, "id", None)` appears character-identically in 2 files — src/agents/run_internal/agent_runner_helpers.py, src/agents/run_internal/tool_planning.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/extensions/models/litellm_model.py:733 — `google_fields and isinstance(google_fields, dict)` appears character-identically in 3 files — src/agents/extensions/models/litellm_model.py, src/agents/models/chatcmpl_converter.py, src/agents/models/chatcmpl_stream_handler.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/handoffs/__init__.py:325 — `input_type is not None and on_handoff is None` appears character-identically in 2 files — src/agents/handoffs/__init__.py, src/agents/realtime/handoffs.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/handoffs/__init__.py:348 — `input_type is not None and type_adapter is not None` appears character-identically in 2 files — src/agents/handoffs/__init__.py, src/agents/realtime/handoffs.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/mcp/_compat.py:183 — `is_http_status_error(error) or is_http_request_error(error)` appears character-identically in 2 files — src/agents/mcp/_compat.py, src/agents/mcp/server.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/run.py:667 — `is_resumed_state and run_state is not None` appears character-identically in 2 files — src/agents/run.py, src/agents/run_internal/run_loop.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/_tool_invocation.py:248 — `isinstance(candidate, str) and candidate` appears character-identically in 2 files — src/agents/_tool_invocation.py, src/agents/run_internal/approvals.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/extensions/memory/advanced_sqlite_session.py:1061 — `isinstance(item, dict) and item.get("role") == "user"` appears character-identically in 2 files — src/agents/extensions/memory/advanced_sqlite_session.py, src/agents/extensions/tool_output_trimmer.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/memory/openai_responses_compaction_session.py:63 — `isinstance(item, dict) and item.get("type") == "compaction"` appears character-identically in 2 files — src/agents/memory/openai_responses_compaction_session.py, src/agents/models/chatcmpl_converter.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/extensions/tool_output_trimmer.py:226 — `isinstance(item, dict) and item.get("type") == "function_call"` appears character-identically in 2 files — src/agents/extensions/tool_output_trimmer.py, src/agents/models/chatcmpl_converter.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/memory/openai_responses_compaction_session.py:872 — `isinstance(item, dict) and item.get("type") == "reasoning"` appears character-identically in 2 files — src/agents/memory/openai_responses_compaction_session.py, src/agents/models/chatcmpl_converter.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
  • Duplicated predicate src/agents/_tool_identity.py:264 — `isinstance(tool_name, str) and tool_name` appears character-identically in 3 files — src/agents/_tool_identity.py, src/agents/agent.py, src/agents/run_internal/tool_execution.py. It is one line, so the duplication detector's token window never sees it; the copies drift when only one is corrected. Give the condition a name and one home.
X23 · Unguarded diagnostic materialisation · Diagnostic log message is built whether or not it is wanted · ×8
  • Diagnostic log message is built whether or not it is wanted src/agents/run.py:2069 — `debug` at line 2069 is called with an argument built by `[item.type for item in items_to_save_turn]` (line 2071), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted src/agents/run_internal/run_loop.py:2555 — `debug` at line 2555 is called with an argument built by `[id(i) for i in filtered.input]` (line 2558), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted src/agents/models/openai_chatcompletions.py:280 — `debug` at line 280 is called with an argument built by `json.dumps(message.model_dump(), indent = 2, ensure_ascii = False)` (line 282), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted src/agents/models/openai_responses.py:626 — `debug` at line 626 is called with an argument built by `x.model_dump()` (line 629), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted src/agents/extensions/models/any_llm_model.py:423 — `debug` at line 423 is called with an argument built by `item.model_dump()` (line 426), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted src/agents/extensions/models/any_llm_model.py:632 — `debug` at line 632 is called with an argument built by `json.dumps(message.model_dump(), indent = 2, ensure_ascii = False)` (line 634), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted src/agents/extensions/models/any_llm_model.py:893 — `debug` at line 893 is called with an argument built by `json.dumps(converted_messages, indent = 2, ensure_ascii = False)` (line 897), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
  • Diagnostic log message is built whether or not it is wanted src/agents/extensions/models/litellm_model.py:270 — `debug` at line 270 is called with an argument built by `json.dumps(message.model_dump(), indent = 2, ensure_ascii = False)` (line 272), whose cost grows with the collection it walks. Python evaluates a call's arguments BEFORE entering the method, so that join/projection runs in full every time this line is reached — and then the level check inside the logger discards the string it produced, because debug is a level a shipped configuration normally leaves off. Nothing here decides beforehand whether the message is wanted: no `isEnabledFor(logging.DEBUG)` test, no debug flag, no `lambda` the logger calls only when the level is on.
X7 · Silent fallback defaults · Silent fallback default in catch · ×8
  • Silent fallback default in catch docs/scripts/translate_docs.py:706 — `git_last_commit_timestamp` swallows every exception into `return 0` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch src/agents/extensions/sandbox/daytona/sandbox.py:247 — `_daytona_exception_types` swallows every exception into `return ()` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch src/agents/extensions/sandbox/e2b/sandbox.py:531 — `_e2b_exception_types` swallows every exception into `return ()` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch src/agents/extensions/sandbox/modal/sandbox.py:139 — `_modal_exception_types` swallows every exception into `return ()` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch src/agents/run_internal/blocked_output.py:726 — `_data_free_tool_output_guardrail_results` swallows every exception into `return ()` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch src/agents/sandbox/capabilities/skills.py:849 — `_resolve_runtime_metadata` swallows every exception into `return []` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch src/agents/sandbox/entries/mounts/patterns.py:138 — `_read_text_if_present` swallows every exception into `return ''` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default in catch src/agents/sandbox/memory/storage.py:205 — `_list_current_selection_items` swallows every exception into `return []` — a data error becomes a silent behavior change with no trail. Log the failure or let it raise. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
D29 · Static Analysis (SAST) · REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
  • REDACTED
D34 · Knowledge Freshness · Orphaned file · ×4
  • Orphaned file src/agents/realtime/events.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file src/agents/realtime/items.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file src/agents/tracing/processor_interface.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
  • Orphaned file src/agents/prompts.py:1 — No one still active in this repository holds living knowledge of this file: everyone who made a meaningful change to it has gone quiet, or what the current team did to it (moves, reformatting, log-level or import edits, renames) never needed understanding it. If it breaks, no one currently understands it. Attach the read to the next change that touches it: have a second person review that change, and leave behind a short comment or test recording what the file is for.
X7 · Silent fallback defaults · Silent fallback default on parse failure · ×3
  • Silent fallback default on parse failure src/agents/models/_trace.py:21 — `sanitize_url_for_trace` returns `''` when `ValueError` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default on parse failure src/agents/run_internal/tool_actions.py:382 — `_supported_keyword_arguments` returns `set()` when `(TypeError, ValueError)` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
  • Silent fallback default on parse failure src/agents/sandbox/memory/storage.py:171 — `read_phase_two_selection` returns `[]` when `json.JSONDecodeError` is raised, with no log or raise — a malformed value silently becomes that default. Log the input or fail validation. If that constant is the correct answer rather than a stand-in for a value that could not be read, say so in a comment on the handler or in the docstring, and the row stops firing.
D16 · Bus Factor · Off-boarding risk · ×1
  • Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 15 significant file(s) lose their only recent owner: src/agents/extensions/experimental/hosted_multi_agent/model.py, src/agents/_tool_identity.py, integration_tests/_contract_support.py, src/agents/agent_tool_state.py, src/agents/run_internal/error_handlers.py, src/agents/logger.py, src/agents/run_internal/tool_use_tracker.py, src/agents/mcp/_compat.py (+7 more). Pair on, review, or document these before any departure.
D26 · Project Cohesion · Projects may be oversized for their cohesion · ×1
  • Projects may be oversized for their cohesion — 1 of 2 project(s) overshoot their size bounds, lowering Project Cohesion to 0.0/10. The most over is `(repository root)` (142611 LoC, 1356 module-visible types across 89 directories). Review these for cohesion — draw the boundary inside the module first (group each responsibility into its own package or directory and keep the cross-boundary members non-public), since splitting a published package moves types between packages and breaks consumers.
D34 · Knowledge Freshness · Orphaned files with no living knowledge · ×1
  • Orphaned files with no living knowledge — 4 of 145 analysed file(s) have no living knowledge left — their last meaningful change has decayed away, so if one breaks, no one currently understands it (counted over production source files of roughly 2,400 bytes or more, excluding vendored, generated, example/demo and scaffolding-template trees and test files identified by path convention, largest first; 145 of the 208 production source files in this repository met that bar). None is large enough to earn a read-through of its own, so this row stands in for the per-file rows rather than raising one each — most significant first: src/agents/realtime/events.py, src/agents/realtime/items.py, src/agents/tracing/processor_interface.py, src/agents/prompts.py. Attach the read to the next change that touches one of them: have a second person review that change, and leave behind a short comment or test recording what the file is for, so the knowledge comes back at the cost of a change you were making anyway.
D36 · Supply-chain Provenance & Signing · REDACTED · ×1
  • REDACTED
M2 · Architecture documentation · No ADRs · ×1
  • No ADRs — No Architecture Decision Records found — no conventional ADR directory, no numbered `NNNN-title` documents in any markup this check reads, and nothing ADR-shaped by content. Design rationale recorded elsewhere (a design-notes tree, a mailing list, pull-request discussion) is not visible to this check and is not re-findable per decision, so a future maintainer cannot ask why one choice was made and get an answer.
Minor — 1 finding(s)
D12 · Dependency Hygiene · Dependency hygiene PARTLY measured · ×1
  • Dependency hygiene PARTLY measured — Python dependencies read, no exact pin to grade for currency — This repository's Python dependencies were read: 13 shipped distribution(s) across 1 manifest(s) (38 development or optional declaration(s) excluded, because a consumer does not install them). Whether any of them is behind its current release is the dependency-CURRENCY question, and no declaration here carries an EXACT pin to ask it about — every one is a floor or a range, which installs the newest release it admits and therefore cannot be behind one. That is a healthy declaration style, NOT a defect and NOT a gap in this analyzer; there is simply no currency question to answer. This is NOT a finding that these dependencies are current or healthy. Lockfiles are deliberately not read (poetry.lock, REDACTED, Pipfile.lock, pdm.lock): the four disagree about dev/optional membership, and misreading one would charge a test-only package a consumer never receives. Known CVEs in the same dependency graph are a separate question, reported under D30.

Appendix B — Reproduction & audit trail

Every external tool invocation behind a deep-scan dimension — the tool, its captured version, the exact command, how many findings it yielded, and a link to the retained raw output. To reproduce any finding: check out the same commit and run the command shown (repo-relative — never an absolute scratch path). The complete raw scanner output is retained verbatim under artifacts/raw/ (indexed in artifacts/raw/index.json); per-invocation exit codes and wall-clock durations are in sidecar.json — kept out of this table so the rendered report stays byte-identical across runs of the same commit.

DimensionToolVersionCommandFindingsRaw output
D28 · Secrets (history)gitleaks—gitleaks detect --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-e368a259e3f0430fad1e2e9f08377e1f/history.json --exit-code 0 --source .0artifacts/raw/gitleaks-history.json
D28 · Secrets (history)gitleaks—gitleaks detect --no-git --no-banner --config /opt/gitleaks-rules/canine-gitleaks.toml --report-format json --report-path /tmp/watchdog-gitleaks-e368a259e3f0430fad1e2e9f08377e1f/tree.json --exit-code 0 --source .0artifacts/raw/gitleaks-tree.json
D29 · Static Analysis (SAST)semgrep—semgrep --config /opt/semgrep-rules/security-audit.yml --config /opt/semgrep-rules/owasp-top-ten.yml --config /opt/semgrep-rules/canine-sast.yml --json --quiet --timeout 10 --timeout-threshold 3 --metrics off --exclude *.arrow --exclude *.avro --exclude *.csv --exclude *.dat --exclude *.db --exclude *.feather --exclude *.geojson --exclude *.h5 --exclude *.hdf5 --exclude *.jsonl --exclude *.log --exclude *.ndjson --exclude *.npy --exclude *.npz --exclude *.orc --exclude *.parquet --exclude *.pickle --exclude *.pkl --exclude *.psv --exclude *.sqlite --exclude *.sqlite3 --exclude *.tfrecord --exclude *.tsv --exclude *.txt .11artifacts/raw/semgrep.json
D30 · Dependency Vulnerabilitiesosv-scanner—osv-scanner --format json --recursive --experimental-disable-plugins transitivedependency/requirements --experimental-disable-plugins dotnet/csproj --experimental-disable-plugins dotnet/nugetcpm .3artifacts/raw/osv-scanner.json
D31 · IaC & Container Securitytrivy—trivy config --format json --quiet .0artifacts/raw/trivy-config.json
D32 · Data Compliance (PII/GDPR)semgrep—semgrep: not applicable — No personal data was found crossing a boundary the PII/GDPR ruleset checks — nothing written to a log or console sink, placed in a URL or query string, or persisted to browser storage. That is a clean result for the LEAK surface only: this ruleset detects personal data escaping, it does not inventory the personal data a repository holds, so it is not evidence that this repository has no personal-data surface. The personal-data map (Appendix C) and the C1-C5 compliance cards are what speak to that.0—
D40 · Network Egress Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; network egress policy is a cluster-native control that may live at the platform/firewall layer, so there is nothing to assess here.0—
D41 · Kernel & Syscall Confinementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; seccomp/AppArmor/SELinux confinement is a workload-level control, so there is nothing to assess here.0—
D42 · Runtime Threat Enforcementruntime-hardening—runtime-hardening: not applicable — No Kubernetes/orchestration workloads found in the repository manifests; runtime threat-detection and admission-control policy are cluster-level controls, so there is nothing to assess here.0—
D43 · Malicious Dependenciesosv-scanner—osv-scanner --format json --recursive --experimental-disable-plugins transitivedependency/requirements --experimental-disable-plugins dotnet/csproj --experimental-disable-plugins dotnet/nugetcpm .0artifacts/raw/osv-scanner.json

Run 01a1a4c5-5603-72bd-8c5c-ea802ff419fe · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.

Downloadable artifacts

Machine-readable and reproducible from this commit + frozen rubric — drop them straight into a contract appendix, a CRA dossier, or a downstream SCA / VEX tool.

⬇ Findings, MITRE CWE-tagged .sarif⬇ Health changelog .md