Public report of openai/openai-agents-python, published 16 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 reportMeasured under the Code Assurance Index, an open standard for code quality, using its published scoring rules (rubric version 2026.11.4). 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, 16 November 2026, 07:13 UTC · Survey ID cd_be0d2b2a57fe4ec2a469a6d32ad832f3
openai/openai-agents-python
Measured 16 November 2026, 07:12 UTC, at code version 64fbde5
CAI scoreAt riskNo change 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,551 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
9 critical841 serious77 minor
15 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
Canine Code Analyzer
Producer
Canine Development
Analyzer
Canine Code Analyzer engine 1.0.0
Measured
16 November 2026, 07:12 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 ▸
51of 51 dimensions measured by tools.
921of 927 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.
51dimensions across 7 lenses, read from 146,551 lines of product code in 2 projects.
openai/openai-agents-python is rated At risk because critical security findings are open, most of them leaked passwords or keys. 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.
Four passwords or keys are open to anyone who can read the repository. Three known security holes in the packages the code depends on can be used by attackers, and one part of the code is no longer understood by anyone working on it. Replacing each exposed password or key, updating the vulnerable packages and having someone learn the forgotten files would close these risks.
The product code is 146,551 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 forThe 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.
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: 131 findings
These 131 critical or serious findings weren't in the previous survey, on 4 November 2026. The first 100 are listed here, and the findings file in the download package lists them all.
Code Duplication · Members sharing a duplicated core (5 members, 50+ identical tokens) src/agents/extensions/sandbox/blaxel/sandbox.py
Code Duplication · Edited copy of a member (66 corresponding lines) examples/memory/compaction_session_example.py
Code Duplication · Edited copy of a member (59 corresponding lines) src/agents/sandbox/session/archive_extraction.py
Code Duplication · Edited copy of a member (87 corresponding lines) examples/basic/retry.py
Code Duplication · Edited copy of a member (52 corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py
Code Duplication · Edited copy of a member (58 corresponding lines) examples/memory/memory_session_hitl_example.py
Code Duplication · Edited copy of a member (31 corresponding lines) integration_tests/_contract_state.py
Code Duplication · Edited copy of a member (30 corresponding lines) src/agents/sandbox/sandboxes/unix_local.py
Code Duplication · Edited copy of a member (27 corresponding lines) examples/financial_research_agent/manager.py
Code Duplication · Edited copy of a member (36 corresponding lines) examples/sandbox/extensions/cloudflare_runner.py
Code Duplication · Edited copy of a member (23 corresponding lines) examples/sandbox/extensions/temporal/temporal_sandbox_tui.py
Code Duplication · Edited copy of a member (26 corresponding lines) examples/financial_research_agent/manager.py
Code Duplication · Edited copy of a member (38 corresponding lines) src/agents/extensions/sandbox/cloudflare/sandbox.py
Code Duplication · Edited copy of a member (53 corresponding lines) examples/handoffs/message_filter.py
Code Duplication · Edited copy of a member (29 corresponding lines) src/agents/sandbox/entries/mounts/providers/azure_blob.py
Code Duplication · Edited copy of a member (24 corresponding lines) examples/mcp/sse_example/main.py
Code Duplication · Edited copy of a member (28 corresponding lines) src/agents/extensions/sandbox/blaxel/mounts.py
Code Duplication · Edited copies of one member (3 members, 22+ corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py
Code Duplication · Edited copy of a member (24 corresponding lines) src/agents/sandbox/_mount_security.py
Code Duplication · Edited copies of one member (3 members, 13+ corresponding lines) src/agents/sandbox/entries/mounts/base.py
Code Duplication · Edited copy of a member (15 corresponding lines) src/agents/extensions/sandbox/e2b/sandbox.py
Code Duplication · Edited copy of a member (13 corresponding lines) examples/sandbox/healthcare_support/data.py
Code Duplication · Edited copy of a member (34 corresponding lines) src/agents/sandbox/session/base_sandbox_session.py
Code Duplication · Edited copy of a member (19 corresponding lines) src/agents/sandbox/entries/mounts/providers/box.py
Code Duplication · Edited copy of a member (14 corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py
Code Duplication · Edited copy of a member (23 corresponding lines) src/agents/sandbox/sandboxes/docker.py
Code Duplication · Edited copy of a member (14 corresponding lines) src/agents/sandbox/entries/mounts/base.py
Code Duplication · Edited copy of a member (9 corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py
Code Duplication · Edited copy of a member (13 corresponding lines) src/agents/sandbox/sandboxes/docker.py
Code Duplication · Edited copies of one member (3 members, 14+ corresponding lines) src/agents/sandbox/session/base_sandbox_session.py
Code Duplication · Edited copies of one member (3 members, 10+ corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py
Code Duplication · Edited copy of a member (18 corresponding lines) src/agents/extensions/sandbox/cloudflare/sandbox.py
Code Duplication · Edited copy of a member (13 corresponding lines) src/agents/sandbox/session/sandbox_client.py
Code Duplication · Edited copy of a member (13 corresponding lines) examples/sandbox/docs/coding_task.py
Code Duplication · Edited copy of a member (11 corresponding lines) src/agents/extensions/sandbox/cloudflare/mounts.py
Code Duplication · Edited copies of one member (4 members, 12+ corresponding lines) src/agents/extensions/sandbox/daytona/mounts.py
Code Duplication · Edited copy of a member (8 corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py
Code Duplication · Edited copies of one member (3 members, 13+ corresponding lines) examples/sandbox/docs/coding_task.py
Code Duplication · Edited copy of a member (11 corresponding lines) src/agents/sandbox/_mount_security.py
Code Duplication · Edited copy of a member (12 corresponding lines) src/agents/sandbox/sandboxes/docker.py
Code Duplication · Edited copy of a member (16 corresponding lines) src/agents/extensions/sandbox/e2b/sandbox.py
Code Duplication · Edited copy of a member (7 corresponding lines) examples/basic/lifecycle_example.py
Code Duplication · Edited copies of one member (3 members, 12+ corresponding lines) src/agents/extensions/sandbox/daytona/sandbox.py
Code Duplication · Edited copy of a member (14 corresponding lines) src/agents/extensions/sandbox/modal/sandbox.py
Code Duplication · Edited copy of a member (8 corresponding lines) examples/financial_research_agent/manager.py
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: 83 findings
These 83 critical or serious findings were in the previous survey, on 4 November 2026, and are gone from this one.
€170,000 to €830,000, for 2,753 to 8,733 hours of work, about 3.4 person-years for 2 to 7 engineers
Difficulty of the problem
Standard, 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.
Size
Large: 146,551 lines of product code
What it is not
Not 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).
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 5.5 out of 10. Code at that level is slower to change than clean code, and we estimate the extra work at 6% to 14% on every change. The history of the code shows how much it changes: about 169,472 lines over the last 90 days, which is about 687,303 lines a year. At that pace, the extra work comes to an estimated 105.4 to 632.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.
156 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; 116 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.
_function_tool_arguments uses tool, so a change to tool can break _function_tool_arguments, while a change to _function_tool_arguments can't break tool.
Position
Below the diagonal: _function_tool_arguments uses a module listed above it, which is the healthy direction.
extensions.experimental.codex uses extensions.experimental.codex.thread, so a change to extensions.experimental.codex.thread can break extensions.experimental.codex, while a change to extensions.experimental.codex can't break extensions.experimental.codex.thread.
Position
Below the diagonal: extensions.experimental.codex uses a module listed above it, which is the healthy direction.
extensions.experimental.codex uses tool, so a change to tool can break extensions.experimental.codex, while a change to extensions.experimental.codex can't break tool.
Position
Below the diagonal: extensions.experimental.codex uses a module listed above it, which is the healthy direction.
extensions.experimental.codex uses usage, so a change to usage can break extensions.experimental.codex, while a change to extensions.experimental.codex can't break usage.
Position
Below the diagonal: extensions.experimental.codex uses a module listed above it, which is the healthy direction.
tracing.traces uses tracing.processor_interface, so a change to tracing.processor_interface can break tracing.traces, while a change to tracing.traces can't break tracing.processor_interface.
Position
Below the diagonal: tracing.traces uses a module listed above it, which is the healthy direction.
models.interface uses model_settings, so a change to model_settings can break models.interface, while a change to models.interface can't break model_settings.
Position
Below the diagonal: models.interface uses a module listed above it, which is the healthy direction.
realtime.openai_realtime uses realtime.config, so a change to realtime.config can break realtime.openai_realtime, while a change to realtime.openai_realtime can't break realtime.config.
Position
Below the diagonal: realtime.openai_realtime uses a module listed above it, which is the healthy direction.
realtime.openai_realtime uses realtime.model, so a change to realtime.model can break realtime.openai_realtime, while a change to realtime.openai_realtime can't break realtime.model.
Position
Below the diagonal: realtime.openai_realtime uses a module listed above it, which is the healthy direction.
realtime.openai_realtime uses realtime.model_events, so a change to realtime.model_events can break realtime.openai_realtime, while a change to realtime.openai_realtime can't break realtime.model_events.
Position
Below the diagonal: realtime.openai_realtime uses a module listed above it, which is the healthy direction.
extensions.models.any_llm_model uses model_settings, so a change to model_settings can break extensions.models.any_llm_model, while a change to extensions.models.any_llm_model can't break model_settings.
Position
Below the diagonal: extensions.models.any_llm_model uses a module listed above it, which is the healthy direction.
extensions.models.any_llm_model uses retry, so a change to retry can break extensions.models.any_llm_model, while a change to extensions.models.any_llm_model can't break retry.
Position
Below the diagonal: extensions.models.any_llm_model uses a module listed above it, which is the healthy direction.
extensions.models.any_llm_model uses items, so a change to items can break extensions.models.any_llm_model, while a change to extensions.models.any_llm_model can't break items.
Position
Below the diagonal: extensions.models.any_llm_model uses a module listed above it, which is the healthy direction.
extensions.models.any_llm_model uses models.interface, so a change to models.interface can break extensions.models.any_llm_model, while a change to extensions.models.any_llm_model can't break models.interface.
Position
Below the diagonal: extensions.models.any_llm_model uses a module listed above it, which is the healthy direction.
extensions.models.litellm_model uses model_settings, so a change to model_settings can break extensions.models.litellm_model, while a change to extensions.models.litellm_model can't break model_settings.
Position
Below the diagonal: extensions.models.litellm_model uses a module listed above it, which is the healthy direction.
extensions.models.litellm_model uses retry, so a change to retry can break extensions.models.litellm_model, while a change to extensions.models.litellm_model can't break retry.
Position
Below the diagonal: extensions.models.litellm_model uses a module listed above it, which is the healthy direction.
extensions.models.litellm_model uses items, so a change to items can break extensions.models.litellm_model, while a change to extensions.models.litellm_model can't break items.
Position
Below the diagonal: extensions.models.litellm_model uses a module listed above it, which is the healthy direction.
extensions.models.litellm_model uses models.interface, so a change to models.interface can break extensions.models.litellm_model, while a change to extensions.models.litellm_model can't break models.interface.
Position
Below the diagonal: extensions.models.litellm_model uses a module listed above it, which is the healthy direction.
models.openai_chatcompletions uses model_settings, so a change to model_settings can break models.openai_chatcompletions, while a change to models.openai_chatcompletions can't break model_settings.
Position
Below the diagonal: models.openai_chatcompletions uses a module listed above it, which is the healthy direction.
models.openai_chatcompletions uses retry, so a change to retry can break models.openai_chatcompletions, while a change to models.openai_chatcompletions can't break retry.
Position
Below the diagonal: models.openai_chatcompletions uses a module listed above it, which is the healthy direction.
models.openai_chatcompletions uses items, so a change to items can break models.openai_chatcompletions, while a change to models.openai_chatcompletions can't break items.
Position
Below the diagonal: models.openai_chatcompletions uses a module listed above it, which is the healthy direction.
models.openai_chatcompletions uses models.interface, so a change to models.interface can break models.openai_chatcompletions, while a change to models.openai_chatcompletions can't break models.interface.
Position
Below the diagonal: models.openai_chatcompletions uses a module listed above it, which is the healthy direction.
models.openai_responses uses model_settings, so a change to model_settings can break models.openai_responses, while a change to models.openai_responses can't break model_settings.
Position
Below the diagonal: models.openai_responses uses a module listed above it, which is the healthy direction.
models.openai_responses uses retry, so a change to retry can break models.openai_responses, while a change to models.openai_responses can't break retry.
Position
Below the diagonal: models.openai_responses uses a module listed above it, which is the healthy direction.
models.openai_responses uses items, so a change to items can break models.openai_responses, while a change to models.openai_responses can't break items.
Position
Below the diagonal: models.openai_responses uses a module listed above it, which is the healthy direction.
models.openai_responses uses models.interface, so a change to models.interface can break models.openai_responses, while a change to models.openai_responses can't break models.interface.
Position
Below the diagonal: models.openai_responses uses a module listed above it, which is the healthy direction.
realtime.session uses realtime.config, so a change to realtime.config can break realtime.session, while a change to realtime.session can't break realtime.config.
Position
Below the diagonal: realtime.session uses a module listed above it, which is the healthy direction.
realtime.session uses realtime.model, so a change to realtime.model can break realtime.session, while a change to realtime.session can't break realtime.model.
Position
Below the diagonal: realtime.session uses a module listed above it, which is the healthy direction.
realtime.session uses _function_tool_arguments, so a change to _function_tool_arguments can break realtime.session, while a change to realtime.session can't break _function_tool_arguments.
Position
Below the diagonal: realtime.session uses a module listed above it, which is the healthy direction.
realtime.session uses realtime.model_events, so a change to realtime.model_events can break realtime.session, while a change to realtime.session can't break realtime.model_events.
Position
Below the diagonal: realtime.session uses a module listed above it, which is the healthy direction.
realtime.session uses realtime.agent, so a change to realtime.agent can break realtime.session, while a change to realtime.session can't break realtime.agent.
Position
Below the diagonal: realtime.session uses a module listed above it, which is the healthy direction.
run_state uses run_internal.run_steps, so a change to run_internal.run_steps can break run_state, while a change to run_state can't break run_internal.run_steps.
Position
Below the diagonal: run_state uses a module listed above it, which is the healthy direction.
testing.model uses models.interface, so a change to models.interface can break testing.model, while a change to testing.model can't break models.interface.
Position
Below the diagonal: testing.model uses a module listed above it, which is the healthy direction.
tracing uses tracing.processor_interface, so a change to tracing.processor_interface can break tracing, while a change to tracing can't break tracing.processor_interface.
Position
Below the diagonal: tracing uses a module listed above it, which is the healthy direction.
src.agents uses tracing.processor_interface, so a change to tracing.processor_interface can break src.agents, while a change to src.agents can't break tracing.processor_interface.
Position
Below the diagonal: src.agents uses a module listed above it, which is the healthy direction.
src.agents uses run_internal.run_steps, so a change to run_internal.run_steps can break src.agents, while a change to src.agents can't break run_internal.run_steps.
Position
Below the diagonal: src.agents uses a module listed above it, which is the healthy direction.
responses_websocket_session uses result, so a change to result can break responses_websocket_session, while a change to responses_websocket_session can't break result.
Position
Below the diagonal: responses_websocket_session uses a module listed above it, which is the healthy direction.
responses_websocket_session uses run_config, so a change to run_config can break responses_websocket_session, while a change to responses_websocket_session can't break run_config.
Position
Below the diagonal: responses_websocket_session uses a module listed above it, which is the healthy direction.
run_internal.tool_execution uses tool, so a change to tool can break run_internal.tool_execution, while a change to run_internal.tool_execution can't break tool.
Position
Below the diagonal: run_internal.tool_execution uses a module listed above it, which is the healthy direction.
run_internal.tool_execution uses run_internal.run_steps, so a change to run_internal.run_steps can break run_internal.tool_execution, while a change to run_internal.tool_execution can't break run_internal.run_steps.
Position
Below the diagonal: run_internal.tool_execution uses a module listed above it, which is the healthy direction.
run_internal.tool_execution uses run_config, so a change to run_config can break run_internal.tool_execution, while a change to run_internal.tool_execution can't break run_config.
Position
Below the diagonal: run_internal.tool_execution uses a module listed above it, which is the healthy direction.
run_internal uses _function_tool_arguments, so a change to _function_tool_arguments can break run_internal, while a change to run_internal can't break _function_tool_arguments.
Position
Below the diagonal: run_internal uses a module listed above it, which is the healthy direction.
run_internal uses models.interface, so a change to models.interface can break run_internal, while a change to run_internal can't break models.interface.
Position
Below the diagonal: run_internal uses a module listed above it, which is the healthy direction.
run_internal uses run_internal.run_steps, so a change to run_internal.run_steps can break run_internal, while a change to run_internal can't break run_internal.run_steps.
Position
Below the diagonal: run_internal uses a module listed above it, which is the healthy direction.
run_internal uses run_internal.tool_execution, so a change to run_internal.tool_execution can break run_internal, while a change to run_internal can't break run_internal.tool_execution.
Position
Below the diagonal: run_internal uses a module listed above it, which is the healthy direction.
At a glance — Code Health · 73% · Adequate · gated by D1, D2 ·
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 category
Findings
Severity
A05:2025 — Injection
11
Medium
A03:2025 — Software Supply Chain Failures
6
High / Critical
A07:2025 — Authentication Failures
5
High / 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); Bring the 8 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with AgentRunner._run_impl (cyclomatic 238), run_loop.start_streaming (cyclomatic 199), turn_resolution.resolve_interrupted_turn (cyclomatic 170).
Ranked by impact ÷ effort. "Helps" is the estimated gain on the 0–100 health score.
Do this
Helps
Effort
Dimension
Keep the ORM/table mapping on a boundary data-model + mapper; leave the domain entity framework-free (map row↔domain through a repository).
Bring the 8 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with AgentRunner._run_impl (cyclomatic 238), run_loop.start_streaming (cyclomatic 199), turn_resolution.resolve_interrupted_turn (cyclomatic 170).
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.
Bring the 31 bodies over 60 down to 60 or less in Cognitive Complexity — start with AgentRunner._run_impl (cognitive 604), run_loop.start_streaming (cognitive 469), ChatCmplStreamHandler.handle_stream (cognitive 319).
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 — 9
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 — 841
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 — 77
Recorded, with no effect on how the codebase functions.
Present so the survey is complete, not because it needs doing.
Could not be resolved — 15
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 51 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 — 51 dimensions across the health lenses
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
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, 921 of 927 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.)
Is there a tool behind the number? Every score below names the method that produced it: Roslyn, git or a scanner, not a narrative.
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.
Method
Backs
Version
Evaluator
Roslyn static analysis
Complexity, cohesion, coupling, dead code, API surface, layering
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.
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. PREREGISTRATION version 20's fallback (adjudication D21-sample3-v3): this rule kind was adjudicated below the 95 % precision gate, so its candidates are counted here and not published, and the score covers only the acronym-spelling and awaitable-suffix rules. The kind returns as rows only after it shows a measured precision; this says nothing about whether these 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 per language (docs/plans/deterministic-engine.md, P5; C# and each NeutralApiArms arm pass): 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.
D32 Data Compliance (PII/GDPR) — 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. `src/agents/models/chatcmpl_converter.py` produced a parse error, so every rule in this engine's `gdpr.yml` was absent there. That absence is NOT a clean result: these rules detect personal data crossing a boundary into a log sink, a URL or browser storage, and a file that was never parsed cannot report any of the three. The rest of the tree analysed normally and its rows above stand; only these files are unaccounted for. You can widen what we reach: fix the syntax error (or exclude the file deliberately) and re-scan to cover it.
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.
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, Scala and Rust source only, and no C#, F#, JavaScript/TypeScript, Dart, Ruby, Scala or Rust 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, Scala and Rust source only, and no C#, JavaScript/TypeScript, Java, Dart, Ruby, Scala or Rust 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.
M4 Documentation accuracy — 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. M4 reads a prose claim (a path, a setting, a variable, a route, a version, a project, an install, a bare project name in a command) only in text identified as English: the cues that tell a claim from an absence, the past, a plan or an example are an English lexicon, and on other text they would let a false claim through. Links, image targets, fenced commands with an explicit path or a package-manager script, and env-fence variables are checked in every language. 'und' is text the identifier could not name (too short, mixed script, no function words).
M4 Documentation accuracy — 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. M4 checks only the claim kinds adjudicated at or above 95 % precision: links and versions (PREREGISTRATION version 9), and artefact counts an order of magnitude off. Paths, command arguments, installs, environment variables, settings, projects, packages, routes, cd targets, infrastructure products and removed modules are read but not checked, and none of them is reported or counted.
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.
X10 Duplicated predicate — 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. 22 further occurrence(s) are not listed individually; the score already reflects all 62.
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, Kotlin and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Java, PHP, Dart, Ruby, Scala, Kotlin or Rust 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, PHP and Rust source only, and no C# was loaded and no JavaScript/TypeScript, Java, Kotlin, Dart, Ruby, Scala, PHP or Rust 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, Kotlin source, and Rust 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.
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 REDACTED Scanning: REDACTED 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.
M4 Documentation accuracy: Documentation accuracy checks links, versions and artefact counts against the tree: other claims (paths, commands, settings, routes) are read but not checked, and it cannot run the onboarding or measure how long a real new joiner takes.
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.
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.
131 method(s) exceeded the cyclomatic complexity threshold of 15; the worst was AgentRunner._run_impl at 238. A further 1 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 streaming.stream_step_items_to_queue at 16 — 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.
+ 126 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 8 bodies over 60 down to 60 or less in Cyclomatic Complexity — start with AgentRunner._run_impl (cyclomatic 238), run_loop.start_streaming (cyclomatic 199), 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.
Detailed fixes: d1_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
+ 226 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
Bring the 31 bodies over 60 down to 60 or less in Cognitive Complexity — start with AgentRunner._run_impl (cognitive 604), run_loop.start_streaming (cognitive 469), 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.
Detailed fixes: d2_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
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.
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).
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).
Detailed fixes: d3_recommendation.md · top locations in Appendix A, every location in findings.md.
What it measures: How much of the production code is copy-pasted: the share of production lines inside a reported copy (every copy of a duplicated block or of an edited member, each line once), 10 at none and 0 at a quarter of the lines.
Method: Code duplication via token-stream sliding windows with type-aware normalization (locals masked, type names preserved), scored on the share of production lines inside a reported copy (each line once; 10 at none, 0 at a quarter). Deterministic.
194 duplicated block group(s) detected. 6.9 % of the production lines (10,099 of 146,551) are in a reported copy. A further 126 rows report members as variants of one another; the share counts each copied line once, however many rows cite it. 169 of the 320 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.
+ 154 more group(s) — more in Appendix A; the complete list is findings.md.
What to do
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).
Resolve the 9 Duplicated block (9 lines × 2) finding(s) in Code Duplication — start with review_protocol.py, async_sqlite_session.py, run.py. — One of this dimension's main actionable groups (9 warning-level).
Resolve the 8 Duplicated block (17 lines × 2) finding(s) in Code Duplication — start with sandbox.py (3), any_llm_model.py, session.py. — One of this dimension's main actionable groups (8 warning-level).
Detailed fixes: d4_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
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).
Detailed fixes: d6_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
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.
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.
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.
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.
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.
Top hotspots: src/agents/run.py (19×238=4522); src/agents/run_internal/run_loop.py (21×199=4179); src/agents/run_state.py (30×115=3450) Repeated repair below the complexity floor: src/agents/extensions/memory/advanced_sqlite_session.py (8 of 8 changes were fixes); src/agents/run_internal/agent_runner_helpers.py (7 of 7 changes were fixes); src/agents/sandbox/session/base_sandbox_session.py (6 of 7 changes were fixes)
Resolve the 32 Hotspot finding(s) in Churn × Complexity Hotspots — start with result.py (2), run.py, run_loop.py. — One of this dimension's main actionable groups (32 warning-level).
Resolve the 21 Repeated repair finding(s) in Churn × Complexity Hotspots — start with advanced_sqlite_session.py, agent_runner_helpers.py, base_sandbox_session.py. — One of this dimension's main actionable groups (21 warning-level).
Detailed fixes: d15_recommendation.md · top locations in Appendix A, every location in findings.md.
Do you agree with this assessment?
D16 · Bus Factor9.0 / 10Exemplary✓ 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.
14 source file(s) have their living knowledge concentrated in one author (≥90% of recent, decayed contribution). The largest is src/agents/extensions/experimental/codex/codex_tool.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
✓ On the Gold path — maintain.
Detailed fixes: d16_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
11 deducted task-comment markers across 146551 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 · ×10src/agents/model_settings.py:160
FixmeCommentdocs/scripts/translate_docs.py:684
What to do
Resolve the 10 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 (10 warning-level).
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).
Detailed fixes: d17_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
1 of 2 build units (Python) flagged as possibly oversized/incoherent.
Projects may be oversized for their cohesionpyproject.toml:1
What to do
Resolve the 1 Projects may be oversized for their cohesion finding(s) in Project Cohesion — start with pyproject.toml. — 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.
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.
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.
What it measures: Whether any secrets were ever committed — scanned across the full git history, not just now.
Method: REDACTED 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.
4 finding(s): 0 critical, 4 high, 0 medium, 0 low. Remediation for historically-committed secrets is credential rotation — they remain in history regardless of later deletion.
REDACTED
REDACTED
What to do
Resolve the 4 REDACTED finding(s) in Secrets (history) — start with REDACTED (4). — One of this dimension's main actionable groups (4 issue-level).
Resolve the 1 Rotate the exposed credentials finding(s) in Secrets (history). — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d28_recommendation.md · top locations in Appendix A, every location in findings.md.
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).
11 finding(s): 0 critical, 0 high, 6 medium, 5 low. semgrep hit a parse error in 2 file(s) — `examples/sandbox/tutorials/misc.py`, `src/agents/models/chatcmpl_converter.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
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).
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).
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.
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.
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).
Resolve the 1 Critical CVE finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 1 Medium CVE finding(s) in Dependency Vulnerabilities — start with REDACTED. — One of this dimension's main actionable groups (1 warning-level).
Detailed fixes: d30_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
7 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/tracing/create.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 knowledgesrc/agents/tracing/create.py:1
Orphaned file · ×6src/agents/tool_guardrails.py:1
Further orphaned files (smaller)
What to do
Resolve the 1 Orphaned knowledge finding(s) in Knowledge Freshness — start with create.py. — One of this dimension's main actionable groups (1 issue-level).
Resolve the 6 Orphaned file finding(s) in Knowledge Freshness — start with tool_guardrails.py, events.py, items.py. — One of this dimension's main actionable groups (6 recommendation-level).
Resolve the 1 Further orphaned files (smaller) finding(s) in Knowledge Freshness. — One of this dimension's main actionable groups (1 recommendation-level).
Detailed fixes: d34_recommendation.md · top locations in Appendix A, every location in findings.md.
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.
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.
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).
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.
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.
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.
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.
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.
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.
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.
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.
Other · Architecture — Whether interfaces stay focused rather than fat — the Interface-Segregation principle (SOLID 'I').
Method: Roslyn scan: public interface declared-member counts (accessors fold into their property/event); fat-interface threshold (over 15 declared members) flagged per type. Each finding also reports the distinct-OPERATION count — members counted by name, so an overload group counts once — which decides whether it states the caller-side ISP harm or the implementer-side burden of an overload set. TypeScript: exported interfaces that declare behaviour, counted over their REQUIRED operations (method signatures and function-typed properties with no `?`, once per signature) — data-shape interfaces and ambient .d.ts declarations are outside the population; JavaScript declares no interfaces and is not applicable. Deterministic, type-level.
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).
Maturity · Maturity — Whether the repository and its projects have a README, and whether it is substantive.
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.
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.
Maturity · Maturity — Whether the repository is organised deliberately: production code and tests are set apart in a way its ecosystem or the repository itself declares.
Method: Filesystem scan: src/test folder separation and namespace-prefix consistency (majority RootNamespace agreement). Exhaustive across projects, deterministic.
Maturity · Maturity — Whether the project's current-state documentation describes the code that exists.
Method: Every current-state document's checkable claims looked up in the tree (links, versions, and artefact counts an order of magnitude off), plus two README checks: an advertised infrastructure product with no footprint, and a module the CHANGELOG records as removed. Deterministic, no model. Advisory.
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.
Do you agree with this assessment?
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.
Do you agree with this assessment?
P2 · Observability7.0 / 10Strong✓ Tool-verified
Readiness · Readiness — Whether the code is diagnosable in production — structured logging, tracing/metrics, health checks.
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.
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.
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.
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.
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.
Do you agree with this assessment?
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 2445) and hands it to `_validate_run_state_json_value`, which calls itself at line 2571 (`_validate_run_state_json_value`) with a piece of `value` (and at line 2575) — 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:2571
`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.
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.
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 2056 is called with an argument built by `[item.type for item in items_to_save_turn]` (line 2058), 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:2056
`debug` at line 2553 is called with an argument built by `[id(i) for i in filtered.input]` (line 2556), 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:2553
`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 427 is called with an argument built by `item.model_dump()` (line 430), 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:427
`debug` at line 636 is called with an argument built by `json.dumps(message.model_dump(), indent = 2, ensure_ascii = False)` (line 638), 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:636
`debug` at line 898 is called with an argument built by `json.dumps(converted_messages, indent = 2, ensure_ascii = False)` (line 902), 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:898
`debug` at line 274 is called with an argument built by `json.dumps(message.model_dump(), indent = 2, ensure_ascii = False)` (line 276), 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:274
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.
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.
Do you agree with this assessment?
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.
Do you agree with this assessment?
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.
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)
Do you agree with this assessment?
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.
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.
Do you agree with this assessment?
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.
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 — 40 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 — 63 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.
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
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 — ~258575 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 — D21 withholds its case and prefix conventions rows: 1 candidate(s) found and not reported.
D22 Internal API Consistency — API consistency is measured on C#, TypeScript, Go 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) — 1 file(s) were not parsed by semgrep — the PII/GDPR ruleset never ran over them
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, Scala and Rust, 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
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 — coverage not measured: this check compares the coverage of the analyzer's own test run across the domain and web layers, and that run measured none here — Test coverage (D8) says why
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 scored: this check counted allocation-aware idioms (Span, pools, stackalloc) per line, which describes what kind of code a repository is rather than whether it has an allocation problem, so it was withdrawn. Nothing here is a finding about your code.
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.
X13 Undrained process stream — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X14 Bypassable address classification — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X15 Unvalidated length from an untrusted reader — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
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
X19 Unrestored process-global state — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
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.
X22 Contradicted release guard — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X24 Document value interpolated into markup unescaped — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
X26 Unsynchronised callback handoff — not applicable — the code was read and holds no site of this kind, so there is nothing for this check to judge
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.
Orphaned knowledge src/agents/tracing/create.py:1— No living knowledge remains for this large file — its last meaningful change has decayed away; if it breaks, no one currently understands it. Schedule a read-through / add characterisation tests before it bites.
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).
FileTooLong: agents/run_state.py src/agents/run_state.py— FileTooLong — 4269 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 3769 over it, 8.54× 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 — 2422 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1922 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 — 2220 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1720 over it, 4.44× 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 — 1846 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 1346 over it, 3.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: 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 — 1468 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 968 over it, 2.94× 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 — 1295 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 795 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: models/chatcmpl_converter.py src/agents/models/chatcmpl_converter.py— FileTooLong — 784 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 284 over it, 1.57× 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 — 780 significant lines (blank, comment-only and punctuation-only lines excluded). The bar is 500 significant lines; this is 280 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.
Hotspot: src/agents/run.py src/agents/run.py:629— src/agents/run.py changed 19 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 238 in AgentRunner._run_impl at line 629. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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:989— src/agents/run_internal/run_loop.py changed 21 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 199 in run_loop.start_streaming at line 989. 19 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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:4186— src/agents/run_state.py changed 30 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 4186. 26 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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 13 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. 12 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/memory/openai_responses_compaction_session.py src/agents/memory/openai_responses_compaction_session.py:273— src/agents/memory/openai_responses_compaction_session.py changed 16 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. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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: src/agents/realtime/session.py src/agents/realtime/session.py:412— src/agents/realtime/session.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 59 in RealtimeSession.on_event at line 412. 10 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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:1446— src/agents/run_internal/session_persistence.py changed 14 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 1446. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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: integration_tests/_contract_support.py integration_tests/_contract_support.py:208— integration_tests/_contract_support.py changed 6 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. 5 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/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. 10 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/models/openai_responses.py src/agents/models/openai_responses.py:2237— src/agents/models/openai_responses.py changed 13 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 34 in Converter._convert_tool at line 2237. 10 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/models/chatcmpl_stream_handler.py src/agents/models/chatcmpl_stream_handler.py:603— src/agents/models/chatcmpl_stream_handler.py changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 129 in ChatCmplStreamHandler.handle_stream at line 603. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/models/chatcmpl_converter.py src/agents/models/chatcmpl_converter.py:559— src/agents/models/chatcmpl_converter.py changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 75 in Converter.items_to_messages at line 559. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/run_context.py src/agents/run_context.py:1369— src/agents/run_context.py changed 5 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/extensions/models/any_llm_model.py src/agents/extensions/models/any_llm_model.py:584— src/agents/extensions/models/any_llm_model.py changed 11 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 21 in AnyLLMModel._get_response_via_chat at line 584. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/voice/models/openai_stt.py src/agents/voice/models/openai_stt.py:320— src/agents/voice/models/openai_stt.py changed 11 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/realtime/openai_realtime.py src/agents/realtime/openai_realtime.py:1044— src/agents/realtime/openai_realtime.py changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 32 in OpenAIRealtimeWebSocketModel._interrupt_audio_playback at line 1044. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/result.py src/agents/result.py:1172— src/agents/result.py changed 11 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/mcp/server.py src/agents/mcp/server.py:1474— src/agents/mcp/server.py changed 9 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 21 in _MCPServerWithClientSession.list_tools at line 1474. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/tracing/processors.py src/agents/tracing/processors.py:134— src/agents/tracing/processors.py changed 7 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 27 in BackendSpanExporter._export_with_deadline at line 134. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +00:00' --full-history --no-merges -- src/agents/tracing/processors.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 7 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/run_internal/tool_execution.py src/agents/run_internal/tool_execution.py:1875— src/agents/run_internal/tool_execution.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 18 in _FunctionToolBatchExecutor._maybe_execute_tool_approval at line 1875. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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: src/agents/sandbox/sandboxes/docker.py src/agents/sandbox/sandboxes/docker.py:1759— src/agents/sandbox/sandboxes/docker.py changed 10 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 17 in DockerSandboxClient.resume at line 1759. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/extensions/models/litellm_model.py src/agents/extensions/models/litellm_model.py:219— src/agents/extensions/models/litellm_model.py changed 5 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 28 in LitellmModel.get_response at line 219. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +00:00' --full-history --no-merges -- src/agents/extensions/models/litellm_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/strict_schema.py src/agents/strict_schema.py:156— src/agents/strict_schema.py changed 3 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/run_internal/model_retry.py src/agents/run_internal/model_retry.py:692— src/agents/run_internal/model_retry.py changed 3 times in last 90 days, and the most complex body those changes touched has cyclomatic complexity 34 in model_retry.stream_response_with_retry at line 692. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +00:00' --full-history --no-merges -- src/agents/run_internal/model_retry.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.
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:1706— `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:1165— `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:1169— `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:2833— `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:3363— `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:3386— `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:3444— `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:3656— `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:3662— `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:3670— `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:3855— `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:5678— `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.
Repeated repair: src/agents/extensions/memory/advanced_sqlite_session.py src/agents/extensions/memory/advanced_sqlite_session.py:996— src/agents/extensions/memory/advanced_sqlite_session.py changed 8 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 15 (its worst body is AdvancedSQLiteSession._extract_tool_name at line 996), AT OR 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(sessions): reject blank SQLite branch names (#5179)”; “fix(extensions): keep SQLite usage capture off the event loop (#4981)”; “fix(sessions): match literal Unicode content in AdvancedSQLiteSession (#5143)”; “fix(extensions): keep the current branch when a forced delete_branch fails (#5081)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +00:00' --full-history --no-merges -- src/agents/extensions/memory/advanced_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/run_internal/agent_runner_helpers.py src/agents/run_internal/agent_runner_helpers.py:132— src/agents/run_internal/agent_runner_helpers.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 agent_runner_helpers.attach_usage_to_span at line 132), AT OR 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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 7 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 BaseSandboxSession._validate_remote_path_access at line 834), AT OR 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/items.py src/agents/items.py:845— src/agents/items.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 13 (its worst body is ItemHelpers.tool_call_output_item at line 845), AT OR 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 wire aliases when replaying Responses items (#5638)”; “fix(deps): bump daytona from 0.155.0 to 0.226.1 (#5487)”; “fix: preserve completed tool outputs when a sibling fails (#5332)”; “fix(core): strip created_by when replaying RunItems as input (#4568)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/memory/sqlite_session.py src/agents/memory/sqlite_session.py:538— src/agents/memory/sqlite_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 11 (its worst body is SQLiteSession.close at line 538), AT OR 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/extensions/memory/encrypt_session.py src/agents/extensions/memory/encrypt_session.py:346— src/agents/extensions/memory/encrypt_session.py changed 6 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 15 (its worst body is EncryptedSession.get_items at line 346), AT OR 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): require encrypted envelopes for session history (#5204)”; “fix(memory): preserve encrypted SQLite history on wrong-key pops (#5083)”; “fix(extensions): preserve filtered history during automatic compaction (#5103)”; “fix(sessions): preserve Session transformations during generation tracking (#4917)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +00:00' --full-history --no-merges -- src/agents/extensions/memory/encrypt_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), AT OR 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/usage.py src/agents/usage.py:257— src/agents/usage.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 15 (its worst body is Usage.add at line 257), AT OR 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(deps): bump daytona from 0.155.0 to 0.226.1 (#5487)”; “fix: normalize nullable token counts in remaining provider paths (#5260)”; “fix(core): detach aggregated request usage entries (#4519)”; “fix(core): count Responses requests without usage (#4453)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +00:00' --full-history --no-merges -- src/agents/usage.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), AT OR 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/run_internal/run_steps.py src/agents/run_internal/run_steps.py:242— src/agents/run_internal/run_steps.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 2 (its worst body is SingleStepResult.generated_items at line 242), AT OR 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/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), AT OR 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/exceptions.py src/agents/exceptions.py:192— src/agents/exceptions.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 14 (its worst body is exceptions._prepare_data_redacted_error at line 192), AT OR 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)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/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), AT OR 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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), AT OR 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/sandbox/apply_patch.py src/agents/sandbox/apply_patch.py:68— src/agents/sandbox/apply_patch.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 WorkspaceEditor.apply_operation at line 68), AT OR 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)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/run_internal/guardrails.py src/agents/run_internal/guardrails.py:69— src/agents/run_internal/guardrails.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 12 (its worst body is guardrails.run_input_guardrails_with_queue at line 69), AT OR 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: report completed input guardrails when a tripwire fires (#5634)”; “fix: preserve completed tool outputs when a sibling fails (#5332)”; “fix: preserve streamed cancellation and pending guardrail cleanup (#5224)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +00:00' --full-history --no-merges -- src/agents/run_internal/guardrails.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 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 13 (its worst body is ComputerAction._execute_action_and_capture at line 226), AT OR 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)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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 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 7 (its worst body is OpenAIConversationsSession._get_items at line 92), AT OR 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)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/voice/models/openai_model_provider.py src/agents/voice/models/openai_model_provider.py:82— src/agents/voice/models/openai_model_provider.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 5 (its worst body is OpenAIVoiceModelProvider._get_client at line 82), AT OR 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)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +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/session/sandbox_session.py src/agents/sandbox/session/sandbox_session.py:333— src/agents/sandbox/session/sandbox_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 15 (its worst body is SandboxSession._apply_trace_finish_data at line 333), AT OR 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)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +00:00' --full-history --no-merges -- src/agents/sandbox/session/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/extensions/sandbox/blaxel/sandbox.py src/agents/extensions/sandbox/blaxel/sandbox.py:590— src/agents/extensions/sandbox/blaxel/sandbox.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 15 (its worst body is BlaxelSandboxSession._exec_internal at line 590), AT OR 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(sandbox): add opt-in bounded workspace outbox reads (#5128)”; “fix(sandbox): settle PTY output before cleanup (#4738)”; “fix(sandbox): clean up PTY startup cancellation (#4750)”. 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-13..2026-11-11, the 90 days ending at the analysed commit. Reproduce with `git log --since='2026-08-13 13:01:18 +00:00' --until='2026-11-11 13:01:18 +00:00' --full-history --no-merges -- src/agents/extensions/sandbox/blaxel/sandbox.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.
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.
Duplicated block (11 lines × 2) src/agents/handoffs/history.py:297— src/agents/handoffs/history.py:297-307 | src/agents/run_state.py:1590-1600 — 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.
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/run.py:635— src/agents/run.py:635-643 | src/agents/run.py:2625-2633 — 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:3879— src/agents/run_state.py:3879-3887 | src/agents/run_state.py:4016-4024 — 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/handoffs/history.py:286— src/agents/handoffs/history.py:286-294 | src/agents/run_internal/session_persistence.py:344-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 (9 lines × 2) src/agents/run_internal/turn_resolution.py:3183— src/agents/run_internal/turn_resolution.py:3183-3191 | src/agents/run_internal/turn_resolution.py:3926-3934 — 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/extensions/models/any_llm_model.py:1478— src/agents/extensions/models/any_llm_model.py:1478-1486 | src/agents/extensions/models/litellm_model.py:383-391 — 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 109 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:1260-1268 — 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/extensions/models/any_llm_model.py:400— src/agents/extensions/models/any_llm_model.py:400-416 | src/agents/extensions/models/any_llm_model.py:482-498 — 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:400` 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:1135— src/agents/extensions/sandbox/daytona/sandbox.py:1135-1151 | 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:1135` 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:1153— src/agents/extensions/sandbox/daytona/sandbox.py:1153-1169 | 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:1153` 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:1173` 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/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:1473— src/agents/run.py:1473-1494 | src/agents/run.py:2199-2214 — 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:1473` 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:1496` calls `take_held_session_write` and `src/agents/run.py:2215` 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:1388— src/agents/run_internal/run_loop.py:1388-1403 | src/agents/run_internal/run_loop.py:1909-1924 — 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:2493— src/agents/run_internal/run_loop.py:2493-2508 | src/agents/run_internal/run_loop.py:2863-2878 — 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:2493` 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:2488` calls `get_output_schema` and `src/agents/run_internal/run_loop.py:2861` 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) 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.
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.
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:2353-2372 — 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:670— src/agents/run_internal/model_retry.py:670-689 | src/agents/run_internal/model_retry.py:885-904 — 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: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.
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.
Duplicated block (13 lines × 2) src/agents/extensions/models/any_llm_model.py:596— src/agents/extensions/models/any_llm_model.py:596-608 | src/agents/extensions/models/any_llm_model.py:733-745 — 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:596` 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:1433-1445 — 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:1319— src/agents/extensions/models/any_llm_model.py:1319-1331 | src/agents/extensions/models/litellm_model.py:898-910 — 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 109 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) 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.
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:510— src/agents/run_state.py:510-519 | src/agents/run_state.py:575-584 — 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:510` 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) integration_tests/_contract_support.py:61— integration_tests/_contract_support.py:61-70 | integration_tests/_contract_support.py:155-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.
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· Edited copy of a member (7 corresponding lines) · ×6
Edited copy of a member (7 corresponding lines) src/agents/voice/input.py:103— src/agents/voice/input.py:103-112 | src/agents/voice/models/openai_stt.py:63-69 — These two members are one piece of code written twice and then edited apart: 7 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.
Edited copy of a member (7 corresponding lines) src/agents/__init__.py:271— src/agents/__init__.py:271-277 | src/agents/memory/__init__.py:39-45 — These two members are one piece of code written twice and then edited apart: 7 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.
Edited copy of a member (7 corresponding lines) examples/basic/lifecycle_example.py:82— examples/basic/lifecycle_example.py:82-88 | examples/basic/lifecycle_example.py:93-99 — These two members are one piece of code written twice and then edited apart: 7 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.
Edited copy of a member (7 corresponding lines) src/agents/extensions/sandbox/cloudflare/mounts.py:80— src/agents/extensions/sandbox/cloudflare/mounts.py:80-86 | src/agents/extensions/sandbox/modal/mounts.py:64-70 — These two members are one piece of code written twice and then edited apart: 7 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.
Edited copy of a member (7 corresponding lines) src/agents/extensions/sandbox/modal/mounts.py:48— src/agents/extensions/sandbox/modal/mounts.py:48-54 | src/agents/sandbox/entries/mounts/base.py:319-325 — These two members are one piece of code written twice and then edited apart: 7 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.
Edited copy of a member (7 corresponding lines) src/agents/sandbox/entries/artifacts.py:43— src/agents/sandbox/entries/artifacts.py:43-49 | src/agents/sandbox/util/checksums.py:9-16 — These two members are one piece of code written twice and then edited apart: 7 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.
Duplicated block (15 lines × 2) src/agents/agent.py:957— src/agents/agent.py:957-971 | src/agents/agent.py:1070-1084 — 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:957` 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.
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/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· Edited copy of a member (4 corresponding lines) · ×6
Edited copy of a member (4 corresponding lines) examples/financial_research_agent/printer.py:15— examples/financial_research_agent/printer.py:15-18 | examples/research_bot/printer.py:10-13 — These two members are one piece of code written twice and then edited apart: 4 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.
Edited copy of a member (4 corresponding lines) examples/voice/static/main.py:36— examples/voice/static/main.py:36-39 | examples/voice/streamed/my_workflow.py:16-19 — These two members are one piece of code written twice and then edited apart: 4 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.
Edited copy of a member (4 corresponding lines) examples/tools/codex.py:100— examples/tools/codex.py:100-103 | examples/tools/codex_same_thread.py:49-52 — These two members are one piece of code written twice and then edited apart: 4 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.
Edited copy of a member (4 corresponding lines) src/agents/sandbox/session/sandbox_client.py:96— src/agents/sandbox/session/sandbox_client.py:96-99 | src/agents/sandbox/snapshot.py:70-73 — These two members are one piece of code written twice and then edited apart: 4 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.
Edited copy of a member (4 corresponding lines) examples/sandbox/tutorials/dataroom_qa/main.py:53— examples/sandbox/tutorials/dataroom_qa/main.py:53-56 | examples/sandbox/tutorials/sandbox_resume/main.py:58-61 — These two members are one piece of code written twice and then edited apart: 4 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.
Edited copy of a member (4 corresponding lines) src/agents/extensions/sandbox/e2b/sandbox.py:175— src/agents/extensions/sandbox/e2b/sandbox.py:175-178 | src/agents/extensions/sandbox/vercel/sandbox.py:156-159 — These two members are one piece of code written twice and then edited apart: 4 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.
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:1093— src/agents/extensions/sandbox/daytona/sandbox.py:1093-1100 | 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· Edited copy of a member (23 corresponding lines) · ×5
Edited copy of a member (23 corresponding lines) src/agents/run_internal/items.py:945— src/agents/run_internal/items.py:945-972 | src/agents/run_internal/items.py:976-998 — These two members are one piece of code written twice and then edited apart: 23 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.
Edited copy of a member (23 corresponding lines) src/agents/run_internal/error_handlers.py:145— src/agents/run_internal/error_handlers.py:145-167 | src/agents/run_internal/error_handlers.py:176-205 — These two members are one piece of code written twice and then edited apart: 23 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.
Edited copy of a member (23 corresponding lines) src/agents/extensions/memory/async_sqlite_session.py:326— src/agents/extensions/memory/async_sqlite_session.py:326-348 | src/agents/memory/sqlite_session.py:262-284 — These two members are one piece of code written twice and then edited apart: 23 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.
Edited copy of a member (23 corresponding lines) examples/sandbox/extensions/temporal/temporal_sandbox_tui.py:631— examples/sandbox/extensions/temporal/temporal_sandbox_tui.py:631-656 | examples/sandbox/extensions/temporal/temporal_sandbox_tui.py:660-682 — These two members are one piece of code written twice and then edited apart: 23 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.
Edited copy of a member (23 corresponding lines) src/agents/sandbox/sandboxes/docker.py:1272— src/agents/sandbox/sandboxes/docker.py:1272-1296 | src/agents/sandbox/sandboxes/docker.py:1299-1321 — These two members are one piece of code written twice and then edited apart: 23 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 (13 corresponding lines) · ×5
Edited copy of a member (13 corresponding lines) src/agents/util/_pretty_print.py:35— src/agents/util/_pretty_print.py:35-47 | src/agents/util/_pretty_print.py:65-79 — These two members are one piece of code written twice and then edited apart: 13 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.
Edited copy of a member (13 corresponding lines) examples/sandbox/healthcare_support/data.py:22— examples/sandbox/healthcare_support/data.py:22-35 | examples/sandbox/tutorials/misc.py:92-104 — These two members are one piece of code written twice and then edited apart: 13 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.
Edited copy of a member (13 corresponding lines) src/agents/sandbox/sandboxes/docker.py:919— src/agents/sandbox/sandboxes/docker.py:919-934 | src/agents/sandbox/session/base_sandbox_session.py:1020-1032 — These two members are one piece of code written twice and then edited apart: 13 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.
Edited copy of a member (13 corresponding lines) src/agents/sandbox/session/sandbox_client.py:78— src/agents/sandbox/session/sandbox_client.py:78-92 | src/agents/sandbox/snapshot.py:54-66 — These two members are one piece of code written twice and then edited apart: 13 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.
Edited copy of a member (13 corresponding lines) examples/sandbox/docs/coding_task.py:102— examples/sandbox/docs/coding_task.py:102-118 | examples/sandbox/sandbox_agent_capabilities.py:265-277 — These two members are one piece of code written twice and then edited apart: 13 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 (12 corresponding lines) · ×5
Edited copy of a member (12 corresponding lines) src/agents/extensions/memory/async_sqlite_session.py:154— src/agents/extensions/memory/async_sqlite_session.py:154-168 | src/agents/memory/sqlite_session.py:211-222 — These two members are one piece of code written twice and then edited apart: 12 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.
Edited copy of a member (12 corresponding lines) src/agents/extensions/memory/async_sqlite_session.py:494— src/agents/extensions/memory/async_sqlite_session.py:494-505 | src/agents/memory/sqlite_session.py:522-536 — These two members are one piece of code written twice and then edited apart: 12 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.
Edited copy of a member (12 corresponding lines) src/agents/model_settings.py:392— src/agents/model_settings.py:392-403 | src/agents/model_settings.py:410-422 — These two members are one piece of code written twice and then edited apart: 12 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.
Edited copy of a member (12 corresponding lines) src/agents/sandbox/sandboxes/docker.py:1927— src/agents/sandbox/sandboxes/docker.py:1927-1939 | src/agents/sandbox/sandboxes/docker.py:1943-1954 — These two members are one piece of code written twice and then edited apart: 12 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.
Edited copy of a member (12 corresponding lines) examples/basic/agent_lifecycle_example.py:111— examples/basic/agent_lifecycle_example.py:111-122 | examples/basic/lifecycle_example.py:150-162 — These two members are one piece of code written twice and then edited apart: 12 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 (14 corresponding lines) · ×5
Edited copy of a member (14 corresponding lines) src/agents/run_internal/items.py:1007— src/agents/run_internal/items.py:1007-1020 | src/agents/run_internal/items.py:1028-1046 — These two members are one piece of code written twice and then edited apart: 14 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.
Edited copy of a member (14 corresponding lines) src/agents/guardrail.py:117— src/agents/guardrail.py:117-130 | src/agents/guardrail.py:168-185 — These two members are one piece of code written twice and then edited apart: 14 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.
Edited copy of a member (14 corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py:495— src/agents/extensions/sandbox/blaxel/sandbox.py:495-508 | src/agents/extensions/sandbox/daytona/sandbox.py:534-547 — These two members are one piece of code written twice and then edited apart: 14 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.
Edited copy of a member (14 corresponding lines) src/agents/sandbox/entries/mounts/base.py:243— src/agents/sandbox/entries/mounts/base.py:243-256 | src/agents/sandbox/entries/mounts/base.py:454-473 — These two members are one piece of code written twice and then edited apart: 14 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.
Edited copy of a member (14 corresponding lines) src/agents/extensions/sandbox/modal/sandbox.py:1855— src/agents/extensions/sandbox/modal/sandbox.py:1855-1868 | src/agents/extensions/sandbox/modal/sandbox.py:1871-1884 — These two members are one piece of code written twice and then edited apart: 14 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.
Duplicated block (19 lines × 2) src/agents/extensions/models/litellm_model.py:240— src/agents/extensions/models/litellm_model.py:240-258 | 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 96 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:240` 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:414— src/agents/extensions/models/litellm_model.py:414-432 | 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 96 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:414` 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:547— src/agents/extensions/models/litellm_model.py:547-565 | 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 96 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:547` 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) 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.
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:258— 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· Edited copy of a member (16 corresponding lines) · ×4
Edited copy of a member (16 corresponding lines) src/agents/_config_coercion.py:51— src/agents/_config_coercion.py:51-66 | src/agents/model_settings.py:318-334 — These two members are one piece of code written twice and then edited apart: 16 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.
Edited copy of a member (16 corresponding lines) src/agents/realtime/_tool_filtering.py:18— src/agents/realtime/_tool_filtering.py:18-33 | src/agents/run_internal/tool_execution.py:577-595 — These two members are one piece of code written twice and then edited apart: 16 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.
Edited copy of a member (16 corresponding lines) src/agents/run_state.py:1382— src/agents/run_state.py:1382-1397 | src/agents/run_state.py:1406-1428 — These two members are one piece of code written twice and then edited apart: 16 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.
Edited copy of a member (16 corresponding lines) src/agents/extensions/sandbox/e2b/sandbox.py:647— src/agents/extensions/sandbox/e2b/sandbox.py:647-663 | src/agents/extensions/sandbox/modal/sandbox.py:321-336 — These two members are one piece of code written twice and then edited apart: 16 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 (10 corresponding lines) · ×4
Edited copy of a member (10 corresponding lines) docs/scripts/translate_docs.py:470— docs/scripts/translate_docs.py:470-479 | docs/scripts/translate_docs.py:568-577 — These two members are one piece of code written twice and then edited apart: 10 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.
Edited copy of a member (10 corresponding lines) src/agents/models/openai_responses.py:389— src/agents/models/openai_responses.py:389-401 | src/agents/run_internal/model_retry.py:362-371 — These two members are one piece of code written twice and then edited apart: 10 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.
Edited copy of a member (10 corresponding lines) src/agents/models/openai_responses.py:1817— src/agents/models/openai_responses.py:1817-1826 | src/agents/tool.py:1480-1489 — These two members are one piece of code written twice and then edited apart: 10 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.
Edited copy of a member (10 corresponding lines) src/agents/extensions/sandbox/blaxel/mounts.py:603— src/agents/extensions/sandbox/blaxel/mounts.py:603-613 | src/agents/extensions/sandbox/blaxel/mounts.py:650-659 — These two members are one piece of code written twice and then edited apart: 10 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 (11 corresponding lines) · ×4
Edited copy of a member (11 corresponding lines) src/agents/mcp/server.py:1193— src/agents/mcp/server.py:1193-1209 | src/agents/mcp/server.py:1226-1236 — These two members are one piece of code written twice and then edited apart: 11 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.
Edited copy of a member (11 corresponding lines) src/agents/extensions/sandbox/cloudflare/mounts.py:57— src/agents/extensions/sandbox/cloudflare/mounts.py:57-70 | src/agents/extensions/sandbox/cloudflare/mounts.py:110-120 — These two members are one piece of code written twice and then edited apart: 11 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.
Edited copy of a member (11 corresponding lines) src/agents/sandbox/_mount_security.py:774— src/agents/sandbox/_mount_security.py:774-784 | src/agents/sandbox/_mount_security.py:788-798 — These two members are one piece of code written twice and then edited apart: 11 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.
Edited copy of a member (11 corresponding lines) examples/run_examples.py:191— examples/run_examples.py:191-201 | examples/tools/web_search_filters.py:71-81 — These two members are one piece of code written twice and then edited apart: 11 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 (8 corresponding lines) · ×4
Edited copy of a member (8 corresponding lines) src/agents/extensions/experimental/codex/codex_tool.py:1280— src/agents/extensions/experimental/codex/codex_tool.py:1280-1287 | src/agents/handoffs/history.py:456-463 — These two members are one piece of code written twice and then edited apart: 8 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.
Edited copy of a member (8 corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py:1319— src/agents/extensions/sandbox/blaxel/sandbox.py:1319-1346 | src/agents/extensions/sandbox/cloudflare/sandbox.py:467-474 — These two members are one piece of code written twice and then edited apart: 8 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.
Edited copy of a member (8 corresponding lines) examples/financial_research_agent/manager.py:126— examples/financial_research_agent/manager.py:126-133 | examples/research_bot/manager.py:53-63 — These two members are one piece of code written twice and then edited apart: 8 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.
Edited copy of a member (8 corresponding lines) src/agents/sandbox/capabilities/skills.py:305— src/agents/sandbox/capabilities/skills.py:305-312 | src/agents/sandbox/capabilities/tools/shell_tool.py:308-316 — These two members are one piece of code written twice and then edited apart: 8 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.
Duplicated block (14 lines × 2) src/agents/extensions/models/any_llm_model.py:949— src/agents/extensions/models/any_llm_model.py:949-962 | src/agents/extensions/models/litellm_model.py:644-657 — 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 109 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:658` calls `_merge_headers` and `src/agents/extensions/models/any_llm_model.py:963` 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:2473— src/agents/run_internal/run_loop.py:2473-2486 | src/agents/run_internal/run_loop.py:2848-2861 — 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:2473` 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:2488` calls `get_output_schema` and `src/agents/run_internal/run_loop.py:2863` 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.
Duplicated block (12 lines × 2) src/agents/run.py:2485— src/agents/run.py:2485-2496 | src/agents/run_internal/run_loop.py:2401-2412 — 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:655— src/agents/run_internal/model_retry.py:655-666 | src/agents/run_internal/model_retry.py:870-881 — 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:655` 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.
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:786— src/agents/models/openai_chatcompletions.py:786-792 | src/agents/models/openai_responses.py:1120-1126 — 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.
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.
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:2571— `from_json` is public, takes a document from its caller (line 2445) and hands it to `_validate_run_state_json_value`, which calls itself at line 2571 (`_validate_run_state_json_value`) with a piece of `value` (and at line 2575) — 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· Edited copy of a member (27 corresponding lines) · ×3
Edited copy of a member (27 corresponding lines) src/agents/tracing/processors.py:525— src/agents/tracing/processors.py:525-553 | src/agents/tracing/processors.py:556-582 — These two members are one piece of code written twice and then edited apart: 27 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.
Edited copy of a member (27 corresponding lines) src/agents/exceptions.py:98— src/agents/exceptions.py:98-124 | src/agents/sandbox/_mount_security.py:1095-1128 — These two members are one piece of code written twice and then edited apart: 27 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.
Edited copy of a member (27 corresponding lines) examples/financial_research_agent/manager.py:138— examples/financial_research_agent/manager.py:138-168 | examples/research_bot/manager.py:66-92 — These two members are one piece of code written twice and then edited apart: 27 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 (30 corresponding lines) · ×3
Edited copy of a member (30 corresponding lines) src/agents/models/openai_provider.py:139— src/agents/models/openai_provider.py:139-178 | src/agents/voice/models/openai_model_provider.py:83-112 — These two members are one piece of code written twice and then edited apart: 30 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.
Edited copy of a member (30 corresponding lines) src/agents/extensions/memory/async_sqlite_session.py:69— src/agents/extensions/memory/async_sqlite_session.py:69-100 | src/agents/memory/sqlite_session.py:230-259 — These two members are one piece of code written twice and then edited apart: 30 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.
Edited copy of a member (30 corresponding lines) src/agents/sandbox/sandboxes/unix_local.py:1188— src/agents/sandbox/sandboxes/unix_local.py:1188-1217 | src/agents/sandbox/sandboxes/unix_local.py:1227-1263 — These two members are one piece of code written twice and then edited apart: 30 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 (19 corresponding lines) · ×3
Edited copy of a member (19 corresponding lines) src/agents/memory/session.py:22— src/agents/memory/session.py:22-53 | src/agents/sandbox/util/blocking_io.py:22-40 — These two members are one piece of code written twice and then edited apart: 19 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.
Edited copy of a member (19 corresponding lines) src/agents/mcp/server.py:1768— src/agents/mcp/server.py:1768-1786 | src/agents/mcp/server.py:1791-1811 — These two members are one piece of code written twice and then edited apart: 19 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.
Edited copy of a member (19 corresponding lines) src/agents/sandbox/entries/mounts/providers/box.py:76— src/agents/sandbox/entries/mounts/providers/box.py:76-94 | src/agents/sandbox/entries/mounts/providers/r2.py:62-81 — These two members are one piece of code written twice and then edited apart: 19 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 (18 corresponding lines) · ×3
Edited copy of a member (18 corresponding lines) src/agents/memory/openai_responses_compaction_session.py:774— src/agents/memory/openai_responses_compaction_session.py:774-793 | src/agents/memory/openai_responses_compaction_session.py:796-813 — These two members are one piece of code written twice and then edited apart: 18 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.
Edited copy of a member (18 corresponding lines) src/agents/extensions/memory/advanced_sqlite_session.py:797— src/agents/extensions/memory/advanced_sqlite_session.py:797-814 | src/agents/extensions/memory/advanced_sqlite_session.py:1749-1808 — These two members are one piece of code written twice and then edited apart: 18 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.
Edited copy of a member (18 corresponding lines) src/agents/extensions/sandbox/cloudflare/sandbox.py:831— src/agents/extensions/sandbox/cloudflare/sandbox.py:831-848 | src/agents/sandbox/session/base_sandbox_session.py:493-512 — These two members are one piece of code written twice and then edited apart: 18 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 (5 corresponding lines) · ×3
Edited copy of a member (5 corresponding lines) .agents/skills/release-candidate-prep/scripts/prepare.py:140— .agents/skills/release-candidate-prep/scripts/prepare.py:140-146 | .github/scripts/update_released_api_contract.py:47-51 — These two members are one piece of code written twice and then edited apart: 5 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.
Edited copy of a member (5 corresponding lines) src/agents/exceptions.py:131— src/agents/exceptions.py:131-135 | src/agents/run_internal/blocked_output.py:46-50 — These two members are one piece of code written twice and then edited apart: 5 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.
Edited copy of a member (5 corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py:342— src/agents/extensions/sandbox/blaxel/sandbox.py:342-347 | src/agents/extensions/sandbox/daytona/sandbox.py:408-412 — These two members are one piece of code written twice and then edited apart: 5 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.
Duplicated block (22 lines × 2) src/agents/extensions/models/any_llm_model.py:692— src/agents/extensions/models/any_llm_model.py:692-713 | 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 118 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:692` 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:574— src/agents/extensions/models/litellm_model.py:574-595 | src/agents/models/openai_responses.py:990-1011 — 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:574` 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.
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.py:1293— src/agents/run.py:1293-1310 | src/agents/run.py:2332-2349 — 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:1293` 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 × 3) src/agents/run_internal/run_loop.py:2499— src/agents/run_internal/run_loop.py:2499-2510 | src/agents/run_internal/run_loop.py:2869-2880 | 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.
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:2611-2619 — 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.
D4 · Code Duplication· Edited copy of a member (24 corresponding lines) · ×3
Edited copy of a member (24 corresponding lines) examples/mcp/sse_example/main.py:32— examples/mcp/sse_example/main.py:32-55 | examples/mcp/streamablehttp_example/main.py:32-55 — These two members are one piece of code written twice and then edited apart: 24 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.
Edited copy of a member (24 corresponding lines) src/agents/sandbox/_mount_security.py:482— src/agents/sandbox/_mount_security.py:482-505 | src/agents/sandbox/_mount_security.py:513-540 — These two members are one piece of code written twice and then edited apart: 24 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.
Edited copy of a member (24 corresponding lines) examples/sandbox/memory.py:70— examples/sandbox/memory.py:70-124 | examples/sandbox/memory_multi_agent_multiturn.py:120-143 — These two members are one piece of code written twice and then edited apart: 24 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 (9 corresponding lines) · ×3
Edited copy of a member (9 corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py:160— src/agents/extensions/sandbox/blaxel/sandbox.py:160-168 | src/agents/extensions/sandbox/modal/sandbox.py:120-131 — These two members are one piece of code written twice and then edited apart: 9 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.
Edited copy of a member (9 corresponding lines) src/agents/sandbox/capabilities/tools/shell_tool.py:205— src/agents/sandbox/capabilities/tools/shell_tool.py:205-213 | src/agents/sandbox/capabilities/tools/view_image.py:114-122 — These two members are one piece of code written twice and then edited apart: 9 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.
Edited copy of a member (9 corresponding lines) examples/model_providers/custom_example_agent.py:49— examples/model_providers/custom_example_agent.py:49-57 | examples/model_providers/custom_example_global.py:51-59 — These two members are one piece of code written twice and then edited apart: 9 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.
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/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.
_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.
D4 · Code Duplication· Members sharing a duplicated core (4 members, 50+ identical tokens) · ×2
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-2399 | src/agents/run.py:2625-2919 — 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· Edited copy of a member (33 corresponding lines) · ×2
Edited copy of a member (33 corresponding lines) src/agents/handoffs/history.py:280— src/agents/handoffs/history.py:280-318 | src/agents/run_state.py:1578-1610 — These two members are one piece of code written twice and then edited apart: 33 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.
Edited copy of a member (33 corresponding lines) src/agents/realtime/openai_realtime.py:500— src/agents/realtime/openai_realtime.py:500-532 | src/agents/realtime/session.py:2122-2160 — These two members are one piece of code written twice and then edited apart: 33 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 (34 corresponding lines) · ×2
Edited copy of a member (34 corresponding lines) src/agents/extensions/experimental/hosted_multi_agent/model.py:940— src/agents/extensions/experimental/hosted_multi_agent/model.py:940-973 | src/agents/models/openai_responses.py:1313-1353 — These two members are one piece of code written twice and then edited apart: 34 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.
Edited copy of a member (34 corresponding lines) src/agents/sandbox/session/base_sandbox_session.py:1227— src/agents/sandbox/session/base_sandbox_session.py:1227-1260 | src/agents/sandbox/session/base_sandbox_session.py:1270-1312 — These two members are one piece of code written twice and then edited apart: 34 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 (36 corresponding lines) · ×2
Edited copy of a member (36 corresponding lines) src/agents/extensions/memory/mongodb_session.py:370— src/agents/extensions/memory/mongodb_session.py:370-406 | src/agents/extensions/memory/mongodb_session.py:530-565 — These two members are one piece of code written twice and then edited apart: 36 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.
Edited copy of a member (36 corresponding lines) examples/sandbox/extensions/cloudflare_runner.py:153— examples/sandbox/extensions/cloudflare_runner.py:153-191 | REDACTED:144-179 — These two members are one piece of code written twice and then edited apart: 36 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 copies of one member (3 members, 15+ corresponding lines) · ×2
Edited copies of one member (3 members, 15+ corresponding lines) src/agents/agent_tool_state.py:213— src/agents/agent_tool_state.py:213-230 | src/agents/agent_tool_state.py:238-252 | src/agents/agent_tool_state.py:260-276 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Edited copies of one member (3 members, 15+ corresponding lines) src/agents/realtime/openai_realtime.py:676— src/agents/realtime/openai_realtime.py:676-702 | src/agents/realtime/testing.py:420-434 | src/agents/realtime/testing.py:438-452 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 15 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (6 corresponding lines) · ×2
Edited copy of a member (6 corresponding lines) src/agents/_tool_invocation.py:298— src/agents/_tool_invocation.py:298-304 | src/agents/sandbox/session/snapshot_lifecycle.py:178-183 — These two members are one piece of code written twice and then edited apart: 6 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.
Edited copy of a member (6 corresponding lines) examples/sandbox/shared_session_workdirs.py:208— examples/sandbox/shared_session_workdirs.py:208-213 | src/agents/sandbox/memory/rollouts.py:143-152 — These two members are one piece of code written twice and then edited apart: 6 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.
Duplicated block (26 lines × 2) src/agents/mcp/server.py:1626— src/agents/mcp/server.py:1626-1651 | src/agents/mcp/server.py:2607-2632 — 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:1172-1197 — 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 (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.
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:393— src/agents/run_state.py:393-408 | src/agents/run_state.py:455-471 — 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 × 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:2380-2394 | src/agents/run.py:2892-2906 — 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.
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.
Duplicated block (14 lines × 3) src/agents/run.py:1722— src/agents/run.py:1722-1735 | src/agents/run_internal/run_loop.py:1859-1872 | src/agents/run_internal/run_loop.py:1950-1963 — 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.
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:1009-1027 | 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· Edited copies of one member (3 members, 13+ corresponding lines) · ×2
Edited copies of one member (3 members, 13+ corresponding lines) src/agents/sandbox/entries/mounts/base.py:135— src/agents/sandbox/entries/mounts/base.py:135-152 | src/agents/sandbox/session/sandbox_client.py:55-74 | src/agents/sandbox/snapshot.py:38-50 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
Edited copies of one member (3 members, 13+ corresponding lines) examples/sandbox/docs/coding_task.py:84— examples/sandbox/docs/coding_task.py:84-98 | examples/sandbox/misc/example_support.py:18-33 | examples/sandbox/shared_session_workdirs.py:163-175 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 13 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
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.
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.
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:1010-1017 | 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.
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.
AgentRunner._run_impl (cyclomatic 238) src/agents/run.py:629— AgentRunner._run_impl has cyclomatic complexity 238 (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.
run_loop.start_streaming (cyclomatic 199) src/agents/run_internal/run_loop.py:989— run_loop.start_streaming has cyclomatic complexity 199 (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.
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.
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.
run_state._build_run_state_from_json (cyclomatic 115) src/agents/run_state.py:4186— 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.
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.
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.
Converter.items_to_messages (cyclomatic 75) src/agents/models/chatcmpl_converter.py:559— 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.
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.
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.
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.
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.
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.
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.
run_state._validate_completed_tool_invocations (cyclomatic 52) src/agents/run_state.py:4833— 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.
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.
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.
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.
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.
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.
session_persistence.resume_pending_session_write (cyclomatic 41) src/agents/run_internal/session_persistence.py:1446— 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.
run_state._copy_pydantic_value (cyclomatic 41) src/agents/run_state.py:447— 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.
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.
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.
run_state._restore_current_response_item_identities (cyclomatic 39) src/agents/run_state.py:5471— run_state._restore_current_response_item_identities has cyclomatic complexity 39 (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.
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.
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.
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.
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.
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.
Converter._convert_tool (cyclomatic 34) src/agents/models/openai_responses.py:2237— 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.
model_retry.stream_response_with_retry (cyclomatic 34) src/agents/run_internal/model_retry.py:692— model_retry.stream_response_with_retry 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.
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.
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.
AgentRunner.run_streamed (cyclomatic 33) src/agents/run.py:2619— 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.
run_loop.run_single_turn_streamed (cyclomatic 33) src/agents/run_internal/run_loop.py:2421— 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.
session_persistence.save_result_to_session (cyclomatic 33) src/agents/run_internal/session_persistence.py:780— 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.
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.
run_state._deserialize_items (cyclomatic 33) src/agents/run_state.py:5172— 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.
OpenAIResponsesWSModel._iter_websocket_response_events (cyclomatic 32) src/agents/models/openai_responses.py:1355— 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.
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.
model_retry._evaluate_retry (cyclomatic 31) src/agents/run_internal/model_retry.py:397— 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.
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.
AnyLLMModel._fetch_chat_response (cyclomatic 30) src/agents/extensions/models/any_llm_model.py:850— 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.
AnyLLMModel._fix_tool_message_ordering (cyclomatic 30) src/agents/extensions/models/any_llm_model.py:1501— 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.
LitellmModel._fix_tool_message_ordering (cyclomatic 30) src/agents/extensions/models/litellm_model.py:747— 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.
MCPServerStreamableHttp.call_tool (cyclomatic 30) src/agents/mcp/server.py:2555— 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.
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.
LitellmModel._fetch_response (cyclomatic 29) src/agents/extensions/models/litellm_model.py:510— 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.
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.
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.
run_loop._finalize_streamed_final_output (cyclomatic 29) src/agents/run_internal/run_loop.py:558— 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.
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.
_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.
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.
LitellmModel.get_response (cyclomatic 28) src/agents/extensions/models/litellm_model.py:219— 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.
session_persistence.prepare_input_with_session (cyclomatic 28) src/agents/run_internal/session_persistence.py:424— session_persistence.prepare_input_with_session 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.
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.
RunState._find_nested_approval_state (cyclomatic 27) src/agents/run_state.py:1221— 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.
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.
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.
_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.
Converter.extract_all_content (cyclomatic 26) src/agents/models/chatcmpl_converter.py:455— 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.
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.
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.
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.
RunState._merge_generated_items_with_processed (cyclomatic 25) src/agents/run_state.py:1854— 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.
_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.
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.
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.
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.
run_state._run_state_raw_items (cyclomatic 23) src/agents/run_state.py:3909— 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.
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.
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.
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.
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.
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.
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.
AnyLLMModel._get_response_via_chat (cyclomatic 21) src/agents/extensions/models/any_llm_model.py:584— 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.
_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.
_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.
Converter._validate_named_function_tool_choice (cyclomatic 21) src/agents/models/openai_responses.py:1923— 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.
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.
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.
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.
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.
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.
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.
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.
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.
session_persistence.defer_interrupted_session_write (cyclomatic 20) src/agents/run_internal/session_persistence.py:1276— 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.
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.
BackendSpanExporter._sanitize_for_openai_tracing_api (cyclomatic 20) src/agents/tracing/processors.py:344— BackendSpanExporter._sanitize_for_openai_tracing_api 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.
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.
AnyLLMModel._stream_response_via_responses (cyclomatic 19) src/agents/extensions/models/any_llm_model.py:468— 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.
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.
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.
session_persistence.rewind_session_items (cyclomatic 19) src/agents/run_internal/session_persistence.py:1624— 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.
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.
RunState._serialize_item (cyclomatic 19) src/agents/run_state.py:2184— 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.
run_state._restore_pydantic_fields_set (cyclomatic 19) src/agents/run_state.py:724— 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.
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.
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.
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.
_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.
_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.
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.
Converter.convert_tool_choice (cyclomatic 18) src/agents/models/openai_responses.py:1829— Converter.convert_tool_choice 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.
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.
_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.
_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.
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.
LitellmModel._convert_gemini_extra_content_to_provider_specific_fields (cyclomatic 17) src/agents/extensions/models/litellm_model.py:688— 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.
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.
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.
OpenAIResponsesWSModel.get_retry_advice (cyclomatic 17) src/agents/models/openai_responses.py:1181— 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.
Converter.convert_tools (cyclomatic 17) src/agents/models/openai_responses.py:2099— Converter.convert_tools 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.
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.
_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.
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.
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.
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.
_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.
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.
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.
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.
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.
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.
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.
RunState._serialize_context_payload (cyclomatic 16) src/agents/run_state.py:1663— 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.
run_state._run_state_program_call_ids (cyclomatic 16) src/agents/run_state.py:3980— 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.
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.
AgentRunner._run_impl (cognitive 604) src/agents/run.py:629— AgentRunner._run_impl has cognitive complexity 604 (threshold 15). Drivers by points: if/else 132 (402 pts), ternaries 32 (71 pts), error handling 20 (61 pts), boolean chains 56, loops 4 (14 pts) (nesting depth added 360). 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.
run_loop.start_streaming (cognitive 469) src/agents/run_internal/run_loop.py:989— run_loop.start_streaming has cognitive complexity 469 (threshold 15). Drivers by points: if/else 126 (327 pts), ternaries 26 (64 pts), error handling 14 (32 pts), boolean chains 31, loops 5 (15 pts) (nesting depth added 267). 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.
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.
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.
Converter.items_to_messages (cognitive 193) src/agents/models/chatcmpl_converter.py:559— 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.
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.
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.
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.
run_state._build_run_state_from_json (cognitive 172) src/agents/run_state.py:4186— 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.
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.
run_state._validate_completed_tool_invocations (cognitive 109) src/agents/run_state.py:4833— 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.
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.
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.
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.
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.
run_state._copy_pydantic_value (cognitive 90) src/agents/run_state.py:447— 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.
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.
model_retry.stream_response_with_retry (cognitive 87) src/agents/run_internal/model_retry.py:692— model_retry.stream_response_with_retry has cognitive complexity 87 (threshold 15). Drivers by points: if/else 17 (49 pts), error handling 5 (15 pts), ternaries 5 (14 pts), boolean chains 6, loops 2 (3 pts) (nesting depth added 52). 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.
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.
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.
LitellmModel._fix_tool_message_ordering (cognitive 80) src/agents/extensions/models/litellm_model.py:747— 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.
_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.
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.
AnyLLMModel._fix_tool_message_ordering (cognitive 72) src/agents/extensions/models/any_llm_model.py:1501— 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.
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.
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.
OpenAIResponsesWSModel._iter_websocket_response_events (cognitive 67) src/agents/models/openai_responses.py:1355— 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.
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.
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.
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.
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.
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.
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.
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.
run_loop._finalize_streamed_final_output (cognitive 57) src/agents/run_internal/run_loop.py:558— 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.
session_persistence.prepare_input_with_session (cognitive 57) src/agents/run_internal/session_persistence.py:424— session_persistence.prepare_input_with_session has cognitive complexity 57 (threshold 15). Drivers by points: if/else 23 (46 pts), ternaries 2 (5 pts), boolean chains 4, loops 1 (2 pts) (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.
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.
session_persistence.resume_pending_session_write (cognitive 52) src/agents/run_internal/session_persistence.py:1446— 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.
run_loop.run_single_turn_streamed (cognitive 48) src/agents/run_internal/run_loop.py:2421— 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.
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.
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.
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.
run_state._deserialize_items (cognitive 47) src/agents/run_state.py:5172— 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.
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.
MCPServerStreamableHttp.call_tool (cognitive 45) src/agents/mcp/server.py:2555— 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.
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.
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.
run_state._run_state_raw_items (cognitive 44) src/agents/run_state.py:3909— 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.
LitellmModel._convert_gemini_extra_content_to_provider_specific_fields (cognitive 43) src/agents/extensions/models/litellm_model.py:688— 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.
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.
Converter._convert_tool (cognitive 43) src/agents/models/openai_responses.py:2237— 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.
session_persistence.save_result_to_session (cognitive 42) src/agents/run_internal/session_persistence.py:780— 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.
run_state._restore_current_response_item_identities (cognitive 42) src/agents/run_state.py:5471— run_state._restore_current_response_item_identities has cognitive complexity 42 (threshold 15). Drivers by points: if/else 23 (28 pts), boolean chains 9, loops 4, ternaries 1 (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.
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.
Converter.extract_all_content (cognitive 39) src/agents/models/chatcmpl_converter.py:455— 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.
_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.
_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.
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.
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.
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.
AnyLLMModel._stream_response_via_responses (cognitive 37) src/agents/extensions/models/any_llm_model.py:468— 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.
run_state._validate_declared_payload (cognitive 36) src/agents/run_state.py:664— 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.
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.
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.
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.
model_retry._evaluate_retry (cognitive 35) src/agents/run_internal/model_retry.py:397— 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.
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.
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.
_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.
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.
_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.
AgentRunner.run_streamed (cognitive 34) src/agents/run.py:2619— 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.
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.
LitellmModel.get_response (cognitive 33) src/agents/extensions/models/litellm_model.py:219— 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.
LitellmModel._fetch_response (cognitive 33) src/agents/extensions/models/litellm_model.py:510— 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.
run_state._restore_pydantic_fields_set (cognitive 33) src/agents/run_state.py:724— 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.
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.
AnyLLMModel._fetch_chat_response (cognitive 32) src/agents/extensions/models/any_llm_model.py:850— 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.
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.
RunState._find_nested_approval_state (cognitive 32) src/agents/run_state.py:1221— 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.
_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.
_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.
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.
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.
RunState._lookup_function_name (cognitive 31) src/agents/run_state.py:2244— 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.
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.
_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.
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.
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.
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.
model_retry.get_response_with_retry (cognitive 30) src/agents/run_internal/model_retry.py:582— 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.
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.
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.
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.
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.
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.
RunState._merge_generated_items_with_processed (cognitive 29) src/agents/run_state.py:1854— 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.
BackendSpanExporter._sanitize_for_openai_tracing_api (cognitive 29) src/agents/tracing/processors.py:344— BackendSpanExporter._sanitize_for_openai_tracing_api has cognitive complexity 29 (threshold 15). Drivers by points: if/else 16 (27 pts), boolean chains 1, 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.
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.
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.
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.
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.
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.
_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.
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.
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.
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.
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.
Converter.convert_tools (cognitive 27) src/agents/models/openai_responses.py:2099— Converter.convert_tools has cognitive complexity 27 (threshold 15). Drivers by points: if/else 9 (18 pts), boolean chains 3, loops 3, ternaries 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.
run_state._run_state_program_call_ids (cognitive 27) src/agents/run_state.py:3980— 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.
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.
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.
run_state._serialize_pending_nested_agent_tool_runs (cognitive 26) src/agents/run_state.py:2968— 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.
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.
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.
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.
_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.
Converter._validate_named_function_tool_choice (cognitive 25) src/agents/models/openai_responses.py:1923— 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.
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.
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.
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.
RunState._serialize_context_payload (cognitive 25) src/agents/run_state.py:1663— 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.
BackendSpanExporter._sanitize_json_compatible_value (cognitive 25) src/agents/tracing/processors.py:648— 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.
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.
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.
_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.
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.
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.
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.
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.
guardrails.run_input_guardrails_with_queue (cognitive 23) src/agents/run_internal/guardrails.py:69— 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.
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.
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.
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.
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.
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.
AnyLLMModel._get_response_via_chat (cognitive 22) src/agents/extensions/models/any_llm_model.py:584— 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.
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.
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.
_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.
_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.
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.
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.
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.
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.
_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.
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.
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.
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.
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.
session_persistence.defer_interrupted_session_write (cognitive 21) src/agents/run_internal/session_persistence.py:1276— 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.
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.
RunState.add_input (cognitive 21) src/agents/run_state.py:1060— 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.
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.
_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.
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.
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.
SQLAlchemySession._pop_item (cognitive 20) src/agents/extensions/memory/sqlalchemy_session.py:586— 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.
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.
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.
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.
OpenAIResponsesWSModel.get_retry_advice (cognitive 20) src/agents/models/openai_responses.py:1181— 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.
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.
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.
session_persistence.rewind_session_items (cognitive 20) src/agents/run_internal/session_persistence.py:1624— 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.
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.
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.
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.
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.
BackendSpanExporter._sanitize_generation_usage_for_openai_tracing_api (cognitive 20) src/agents/tracing/processors.py:600— 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.
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.
_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.
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.
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.
AnyLLMModel._sanitize_any_llm_responses_value (cognitive 19) src/agents/extensions/models/any_llm_model.py:1446— 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.
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.
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.
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.
session_persistence.held_session_items_for_save (cognitive 19) src/agents/run_internal/session_persistence.py:1225— 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.
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.
RunState._serialize_item (cognitive 19) src/agents/run_state.py:2184— 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.
run_state._copy_json_compatible_value (cognitive 19) src/agents/run_state.py:392— 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.
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.
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.
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.
LitellmConverter.convert_message_to_openai (cognitive 18) src/agents/extensions/models/litellm_model.py:932— 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.
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.
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.
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.
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.
session_persistence._held_items_safe_to_settle (cognitive 18) src/agents/run_internal/session_persistence.py:1144— 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.
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.
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.
BatchTraceProcessor._export_batches (cognitive 18) src/agents/tracing/processors.py:840— 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.
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.
_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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
_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.
_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.
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.
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.
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.
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.
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.
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.
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.
_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.
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.
guardrails.run_input_guardrails (cognitive 16) src/agents/run_internal/guardrails.py:136— guardrails.run_input_guardrails has cognitive complexity 16 (threshold 15). Drivers by points: loops 4 (9 pts), if/else 3 (6 pts), error handling 1 (nesting depth added 8). To reduce it, break up the iteration: give each loop body a named function, and split a multi-phase loop into one function per phase so no single body carries the whole pipeline.
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.
model_retry._normalize_retry_error (cognitive 16) src/agents/run_internal/model_retry.py:124— 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.
run_loop._safe_redacted_persistence_error (cognitive 16) src/agents/run_internal/run_loop.py:763— 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.
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.
run_state._deserialize_processed_response (cognitive 16) src/agents/run_state.py:3241— 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.
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.
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· Edited copy of a member (124 corresponding lines) · ×1
Edited copy of a member (124 corresponding lines) src/agents/extensions/models/any_llm_model.py:596— src/agents/extensions/models/any_llm_model.py:596-719 | src/agents/models/openai_chatcompletions.py:229-390 — These two members are one piece of code written twice and then edited apart: 124 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 (91 corresponding lines) · ×1
Edited copy of a member (91 corresponding lines) src/agents/extensions/models/any_llm_model.py:1504— src/agents/extensions/models/any_llm_model.py:1504-1594 | src/agents/extensions/models/litellm_model.py:750-871 — These two members are one piece of code written twice and then edited apart: 91 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 (71 corresponding lines) · ×1
Edited copy of a member (71 corresponding lines) src/agents/extensions/memory/async_sqlite_session.py:356— src/agents/extensions/memory/async_sqlite_session.py:356-426 | src/agents/memory/sqlite_session.py:368-445 — These two members are one piece of code written twice and then edited apart: 71 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 (92 corresponding lines) · ×1
Edited copy of a member (92 corresponding lines) src/agents/handoffs/__init__.py:296— src/agents/handoffs/__init__.py:296-407 | src/agents/realtime/handoffs.py:117-208 — These two members are one piece of code written twice and then edited apart: 92 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 (41 corresponding lines) · ×1
Edited copy of a member (41 corresponding lines) src/agents/run_internal/items.py:611— src/agents/run_internal/items.py:611-670 | src/agents/run_internal/items.py:678-718 — These two members are one piece of code written twice and then edited apart: 41 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 (76 corresponding lines) · ×1
Edited copy of a member (76 corresponding lines) src/agents/extensions/models/any_llm_model.py:733— src/agents/extensions/models/any_llm_model.py:733-808 | src/agents/models/openai_chatcompletions.py:440-533 — These two members are one piece of code written twice and then edited apart: 76 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 copies of one member (3 members, 72+ corresponding lines) · ×1
Edited copies of one member (3 members, 72+ corresponding lines) src/agents/extensions/memory/advanced_sqlite_session.py:427— src/agents/extensions/memory/advanced_sqlite_session.py:427-507 | src/agents/extensions/memory/async_sqlite_session.py:249-321 | src/agents/memory/sqlite_session.py:287-358 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 72 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (47 corresponding lines) · ×1
Edited copy of a member (47 corresponding lines) src/agents/run_internal/guardrails.py:143— src/agents/run_internal/guardrails.py:143-193 | src/agents/run_internal/guardrails.py:203-249 — These two members are one piece of code written twice and then edited apart: 47 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 (50 corresponding lines) · ×1
Edited copy of a member (50 corresponding lines) src/agents/realtime/session.py:955— src/agents/realtime/session.py:955-1004 | src/agents/run_internal/tool_execution.py:1248-1303 — These two members are one piece of code written twice and then edited apart: 50 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 (20 corresponding lines) · ×1
Edited copy of a member (20 corresponding lines) src/agents/run_state.py:4118— src/agents/run_state.py:4118-4137 | src/agents/run_state.py:4143-4162 — These two members are one piece of code written twice and then edited apart: 20 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 (22 corresponding lines) · ×1
Edited copy of a member (22 corresponding lines) src/agents/mcp/manager.py:479— src/agents/mcp/manager.py:479-500 | src/agents/mcp/manager.py:582-605 — These two members are one piece of code written twice and then edited apart: 22 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 (35 corresponding lines) · ×1
Edited copy of a member (35 corresponding lines) src/agents/extensions/memory/dapr_session.py:85— src/agents/extensions/memory/dapr_session.py:85-119 | src/agents/extensions/memory/redis_session.py:372-406 — These two members are one piece of code written twice and then edited apart: 35 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 (25 corresponding lines) · ×1
Edited copy of a member (25 corresponding lines) src/agents/run_internal/tool_execution.py:2801— src/agents/run_internal/tool_execution.py:2801-2825 | src/agents/run_internal/tool_execution.py:2836-2865 — These two members are one piece of code written twice and then edited apart: 25 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 copies of one member (3 members, 11+ corresponding lines) · ×1
Edited copies of one member (3 members, 11+ corresponding lines) src/agents/extensions/experimental/codex/codex_options.py:27— src/agents/extensions/experimental/codex/codex_options.py:27-37 | src/agents/extensions/experimental/codex/thread_options.py:42-52 | src/agents/extensions/experimental/codex/turn_options.py:26-36 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 11 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (4 members, 19+ corresponding lines) · ×1
Edited copies of one member (4 members, 19+ corresponding lines) src/agents/run_internal/tool_execution.py:2418— src/agents/run_internal/tool_execution.py:2418-2436 | src/agents/run_internal/tool_execution.py:2449-2467 | src/agents/run_internal/tool_execution.py:2480-2498 | src/agents/run_internal/tool_execution.py:2511-2529 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 19 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
Duplicated block (71–78 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-2394 — 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.
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.
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.
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.
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.
Duplicated block (33 lines × 2) src/agents/run_internal/run_loop.py:2581— src/agents/run_internal/run_loop.py:2581-2613 | src/agents/run_internal/run_loop.py:3005-3037 — 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:2581` 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 (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.
Duplicated block (28–29 lines × 2) src/agents/extensions/models/any_llm_model.py:629— src/agents/extensions/models/any_llm_model.py:629-656 | 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 118 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.
Duplicated block (21–28 lines × 2) src/agents/extensions/models/any_llm_model.py:978— src/agents/extensions/models/any_llm_model.py:978-998 | src/agents/models/openai_chatcompletions.py:755-782 — 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 118 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.
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.
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.
Duplicated block (23–24 lines × 2) src/agents/run.py:1789— src/agents/run.py:1789-1812 | src/agents/run.py:1897-1919 — 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:1789` 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 (21–22 lines × 2) src/agents/extensions/models/any_llm_model.py:520— src/agents/extensions/models/any_llm_model.py:520-540 | 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.
Duplicated block (19–21 lines × 2) src/agents/run.py:1408— src/agents/run.py:1408-1428 | src/agents/run.py:2149-2167 — 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:1407` calls `discard_held_current_response` and `src/agents/run.py:2148` 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 (20–21 lines × 2) src/agents/run_internal/run_loop.py:1859— src/agents/run_internal/run_loop.py:1859-1878 | src/agents/run_internal/run_loop.py:1950-1970 — 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:1950` 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 (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.
Duplicated block (17–19 lines × 2) src/agents/run.py:1508— src/agents/run.py:1508-1526 | src/agents/run.py:1673-1689 — 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:1508` 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–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.
Duplicated block (13–18 lines × 2) src/agents/extensions/models/any_llm_model.py:1582— src/agents/extensions/models/any_llm_model.py:1582-1594 | src/agents/extensions/models/litellm_model.py:854-871 — 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 109 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.
Duplicated block (15–18 lines × 2) src/agents/run_internal/run_loop.py:2557— src/agents/run_internal/run_loop.py:2557-2574 | src/agents/run_internal/run_loop.py:2991-3005 — 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:2557` 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–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.
Duplicated block (12–16 lines × 3) src/agents/extensions/models/any_llm_model.py:881— src/agents/extensions/models/any_llm_model.py:881-892 | src/agents/extensions/models/litellm_model.py:556-571 | src/agents/models/openai_chatcompletions.py:636-651 — 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 109 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:556` 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 (15–16 lines × 2) src/agents/extensions/models/any_llm_model.py:497— src/agents/extensions/models/any_llm_model.py:497-511 | 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:497` 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 (14–16 lines × 2) src/agents/extensions/models/any_llm_model.py:1554— src/agents/extensions/models/any_llm_model.py:1554-1567 | src/agents/extensions/models/litellm_model.py:819-834 — 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 109 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 (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.
Duplicated block (13 lines × 3) src/agents/extensions/models/any_llm_model.py:630— src/agents/extensions/models/any_llm_model.py:630-642 | src/agents/extensions/models/litellm_model.py:268-280 | 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 109 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:282` calls `hasattr` and `src/agents/extensions/models/any_llm_model.py:644` 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 (11–12 lines × 2) src/agents/run_internal/run_loop.py:1341— src/agents/run_internal/run_loop.py:1341-1351 | src/agents/run_internal/run_loop.py:2407-2418 — 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–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.
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:1582-1587 — 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 (10 lines × 4) src/agents/extensions/models/any_llm_model.py:1304— src/agents/extensions/models/any_llm_model.py:1304-1313 | src/agents/extensions/models/litellm_model.py:883-892 | 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 109 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.
Near-duplicate member pair (58 shared lines) src/agents/extensions/sandbox/daytona/sandbox.py:1093— src/agents/extensions/sandbox/daytona/sandbox.py:1093-1169 | 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· Edited copy of a member (66 corresponding lines) · ×1
Edited copy of a member (66 corresponding lines) examples/memory/compaction_session_example.py:16— examples/memory/compaction_session_example.py:16-81 | examples/memory/compaction_session_stateless_example.py:15-80 — These two members are one piece of code written twice and then edited apart: 66 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 (59 corresponding lines) · ×1
Edited copy of a member (59 corresponding lines) src/agents/sandbox/session/archive_extraction.py:66— src/agents/sandbox/session/archive_extraction.py:66-132 | src/agents/sandbox/session/archive_extraction.py:142-200 — These two members are one piece of code written twice and then edited apart: 59 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 (87 corresponding lines) · ×1
Edited copy of a member (87 corresponding lines) examples/basic/retry.py:22— examples/basic/retry.py:22-108 | examples/basic/retry_litellm.py:22-110 — These two members are one piece of code written twice and then edited apart: 87 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 (52 corresponding lines) · ×1
Edited copy of a member (52 corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py:743— src/agents/extensions/sandbox/blaxel/sandbox.py:743-794 | src/agents/extensions/sandbox/daytona/sandbox.py:1172-1227 — These two members are one piece of code written twice and then edited apart: 52 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 (58 corresponding lines) · ×1
Edited copy of a member (58 corresponding lines) examples/memory/memory_session_hitl_example.py:63— examples/memory/memory_session_hitl_example.py:63-122 | examples/memory/openai_session_hitl_example.py:63-120 — These two members are one piece of code written twice and then edited apart: 58 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 (31 corresponding lines) · ×1
Edited copy of a member (31 corresponding lines) integration_tests/_contract_state.py:185— integration_tests/_contract_state.py:185-215 | integration_tests/_contract_state.py:336-368 — These two members are one piece of code written twice and then edited apart: 31 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 (26 corresponding lines) · ×1
Edited copy of a member (26 corresponding lines) examples/financial_research_agent/manager.py:79— examples/financial_research_agent/manager.py:79-104 | examples/research_bot/manager.py:22-50 — These two members are one piece of code written twice and then edited apart: 26 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 (38 corresponding lines) · ×1
Edited copy of a member (38 corresponding lines) src/agents/extensions/sandbox/cloudflare/sandbox.py:508— src/agents/extensions/sandbox/cloudflare/sandbox.py:508-551 | src/agents/extensions/sandbox/cloudflare/sandbox.py:554-591 — These two members are one piece of code written twice and then edited apart: 38 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 (53 corresponding lines) · ×1
Edited copy of a member (53 corresponding lines) examples/handoffs/message_filter.py:75— examples/handoffs/message_filter.py:75-188 | examples/handoffs/message_filter_streaming.py:75-188 — These two members are one piece of code written twice and then edited apart: 53 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 (29 corresponding lines) · ×1
Edited copy of a member (29 corresponding lines) src/agents/sandbox/entries/mounts/providers/azure_blob.py:59— src/agents/sandbox/entries/mounts/providers/azure_blob.py:59-87 | src/agents/sandbox/entries/mounts/providers/s3.py:82-113 — These two members are one piece of code written twice and then edited apart: 29 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 (28 corresponding lines) · ×1
Edited copy of a member (28 corresponding lines) src/agents/extensions/sandbox/blaxel/mounts.py:535— src/agents/extensions/sandbox/blaxel/mounts.py:535-562 | src/agents/sandbox/entries/mounts/base.py:396-428 — These two members are one piece of code written twice and then edited apart: 28 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 copies of one member (3 members, 22+ corresponding lines) · ×1
Edited copies of one member (3 members, 22+ corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py:176— src/agents/extensions/sandbox/blaxel/sandbox.py:176-197 | src/agents/extensions/sandbox/daytona/sandbox.py:146-168 | src/agents/extensions/sandbox/modal/sandbox.py:219-240 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 22 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copy of a member (15 corresponding lines) · ×1
Edited copy of a member (15 corresponding lines) src/agents/extensions/sandbox/e2b/sandbox.py:96— src/agents/extensions/sandbox/e2b/sandbox.py:96-112 | src/agents/extensions/sandbox/modal/sandbox.py:186-200 — These two members are one piece of code written twice and then edited apart: 15 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 copies of one member (3 members, 14+ corresponding lines) · ×1
Edited copies of one member (3 members, 14+ corresponding lines) src/agents/sandbox/session/base_sandbox_session.py:1076— src/agents/sandbox/session/base_sandbox_session.py:1076-1089 | src/agents/sandbox/session/base_sandbox_session.py:1098-1118 | src/agents/sandbox/session/base_sandbox_session.py:1127-1147 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 14 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 10+ corresponding lines) · ×1
Edited copies of one member (3 members, 10+ corresponding lines) src/agents/extensions/sandbox/blaxel/sandbox.py:1035— src/agents/extensions/sandbox/blaxel/sandbox.py:1035-1044 | src/agents/extensions/sandbox/daytona/sandbox.py:911-921 | src/agents/extensions/sandbox/modal/sandbox.py:1190-1201 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 10 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (4 members, 12+ corresponding lines) · ×1
Edited copies of one member (4 members, 12+ corresponding lines) src/agents/extensions/sandbox/daytona/mounts.py:207— src/agents/extensions/sandbox/daytona/mounts.py:207-218 | src/agents/extensions/sandbox/daytona/mounts.py:248-259 | src/agents/extensions/sandbox/e2b/mounts.py:92-104 | src/agents/extensions/sandbox/e2b/mounts.py:134-146 — These 4 members are one piece of code written 4 times and then edited apart: every two of them correspond over at least 12 lines, 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 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. Left alone, the next edit has to be made 4 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 12+ corresponding lines) · ×1
Edited copies of one member (3 members, 12+ corresponding lines) src/agents/extensions/sandbox/daytona/sandbox.py:244— src/agents/extensions/sandbox/daytona/sandbox.py:244-255 | src/agents/extensions/sandbox/e2b/sandbox.py:528-539 | src/agents/extensions/sandbox/modal/sandbox.py:135-147 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 12 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
D4 · Code Duplication· Edited copies of one member (3 members, 5+ corresponding lines) · ×1
Edited copies of one member (3 members, 5+ corresponding lines) examples/sandbox/misc/workspace_apply_patch.py:14— examples/sandbox/misc/workspace_apply_patch.py:14-19 | src/agents/sandbox/capabilities/skills.py:516-523 | src/agents/sandbox/memory/storage.py:18-22 — These 3 members are one piece of code written 3 times and then edited apart: every two of them correspond over at least 5 lines, 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 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. Left alone, the next edit has to be made 3 times and the copies will drift further apart.
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.
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.
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.
Duplicated block (46–48 lines × 2) examples/memory/compaction_session_example.py:29— examples/memory/compaction_session_example.py:29-76 | examples/memory/compaction_session_stateless_example.py:30-75 — 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:29` 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:29` calls `ModelSettings` and `examples/memory/compaction_session_example.py:28` 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 (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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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:1107-1122 | 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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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:1013-1020 | 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.
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.
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.
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.
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.
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:1173-1178 | 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.
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.
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.
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:699— `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:738— `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.
+ 15 more in this group — see findings.md.
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:2056— `debug` at line 2056 is called with an argument built by `[item.type for item in items_to_save_turn]` (line 2058), 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:2553— `debug` at line 2553 is called with an argument built by `[id(i) for i in filtered.input]` (line 2556), 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:427— `debug` at line 427 is called with an argument built by `item.model_dump()` (line 430), 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:636— `debug` at line 636 is called with an argument built by `json.dumps(message.model_dump(), indent = 2, ensure_ascii = False)` (line 638), 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:898— `debug` at line 898 is called with an argument built by `json.dumps(converted_messages, indent = 2, ensure_ascii = False)` (line 902), 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:274— `debug` at line 274 is called with an argument built by `json.dumps(message.model_dump(), indent = 2, ensure_ascii = False)` (line 276), 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.
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.
Orphaned file src/agents/tool_guardrails.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/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/repl.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.
Silent fallback default on parse failure src/agents/models/_trace.py:23— `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.
Off-boarding risk: anonymized user #1 — If anonymized user #1 becomes unavailable, 14 significant file(s) lose their only recent owner: src/agents/extensions/experimental/codex/codex_tool.py, src/agents/extensions/experimental/hosted_multi_agent/model.py, integration_tests/_contract_validation.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 (+6 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 pyproject.toml:1— `(repository root)` (142632 LoC, 1357 module-visible types across 89 directories) overshoots its size bounds. 1 of 2 build unit(s) (Python) overshoot their size bounds, lowering Project Cohesion to 0.0/10. 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.
D28 · Secrets (history)· Rotate the exposed credentials · ×1
REDACTED
D34 · Knowledge Freshness· Further orphaned files (smaller) · ×1
Further orphaned files (smaller) — 6 smaller file(s) also have no living knowledge — folded into the freshness score and metrics rather than raised one row each — most significant first: src/agents/tool_guardrails.py, src/agents/realtime/events.py, src/agents/realtime/items.py, src/agents/tracing/processor_interface.py, src/agents/repl.py, src/agents/prompts.py (7 orphaned of 145 analysed files in total, 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). 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.
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.
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.
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. semgrep could not parse 1 file(s) — `src/agents/models/chatcmpl_converter.py` — so the PII/GDPR sweep did not cover them at all.
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.
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.
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.
Run 01a1e333-5bc7-7c12-b4d0-4d3f6bf14958 · every finding is also locatable in findings.md, and the complete scoring record (with exit codes + durations) in sidecar.json.
Issues: 9 · Warnings: 841 · Recommendations: 76 · Info: 1 — Appendix A · all findings · full markdown report.
Generated by the Canine Code Analyzer: deterministic code-health analysis. 16-11-2026 @ 07:12 UTC.
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.