Skip to content

chore(harness): remove banner comments, restating comments and dead in_loop_thread - #44161

Merged
mateo-berri merged 1 commit into
mainfrom
litellm_techdebt_20261002
Oct 2, 2026
Merged

mateo-berri merged 1 commit into
mainfrom
litellm_techdebt_20261002

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

How it solves it:

  • Deletes section-divider banner comments in five new harness modules
  • Deletes the uncalled _LoopThread.in_loop_thread method
  • Deletes comments that restate the code next to them
  • Comment and dead-code removals only, no runtime change

User Flow

Before: a developer runs Claude Code through litellm.agent() on an Anthropic model, and it works

  1. They call litellm.agent(Harness.CLAUDE_CODE, "create hello.txt ...", sandbox=sandbox.local(dir), model="anthropic/claude-haiku-4-5")
  2. Claude Code writes hello.txt, and the Result reports stop reason done, the file change, token usage and a non-zero cost
  3. The same prompt with litellm.aagent(..., stream=True) streams Text events and ends with one Done event
  4. Calling litellm.agent() from inside a running event loop raises the "use await litellm.aagent" error

After: the same developer sees exactly the same results, since only unused code and comments are gone

  1. They call litellm.agent(Harness.CLAUDE_CODE, "create hello.txt ...", sandbox=sandbox.local(dir), model="anthropic/claude-haiku-4-5")
  2. Claude Code writes hello.txt, and the Result reports stop reason done, the file change, token usage and a non-zero cost
  3. The same prompt with litellm.aagent(..., stream=True) streams Text events and ends with one Done event
  4. Calling litellm.agent() from inside a running event loop raises the "use await litellm.aagent" error

Findings (run 2026-10-02, window 2026-10-01 07:45 UTC to 2026-10-02 07:45 UTC)

  1. 0f6a06a feat: add litellm.agent() (feat: add litellm.agent() to run claude code, codex, opencode and deep agents through the ai gateway #43885) added # ---- / # -- name -- section banners in litellm/harness/endpoint.py, litellm/harness/runtime.py, litellm/harness/sandbox/docker.py, litellm/llms/deepagents/harness/transformation.py and litellm/llms/deepagents/harness/sandbox_backend.py. None is business logic, a tool directive, or a linked TODO. Deleted
  2. 0f6a06a (feat: add litellm.agent() to run claude code, codex, opencode and deep agents through the ai gateway #43885) added _LoopThread.in_loop_thread in litellm/harness/sync.py, which nothing in litellm/, enterprise/ or tests/ calls. Deleted
  3. 0f6a06a (feat: add litellm.agent() to run claude code, codex, opencode and deep agents through the ai gateway #43885) added # Injected client (tests); production uses LiteLLM's shared cached client. in ModelEndpoint.__init__, which repeats the _gateway_client docstring. Deleted
  4. 0f6a06a (feat: add litellm.agent() to run claude code, codex, opencode and deep agents through the ai gateway #43885) added two comments in litellm/__init__.py that restate _AGENT_EXPORTS and the lazy litellm.harness branch of __getattr__. Deleted

Nothing was absorbed: no other litellm_techdebt_ PR was open. No budget file moved

Deliberately left alone

Screenshots / Proof of Fix

Parity A/B through the real end-user client: the same script calls litellm.agent() and litellm.aagent() with Claude Code 2.1.287 (installed with npm install -g @anthropic-ai/claude-code) on real anthropic/claude-haiku-4-5, once from a worktree at the merge base and once from a worktree at the tip, each run asserting litellm.__file__ resolves inside its worktree. Model text can differ by punctuation between runs; everything else must match

Before (7d50a31)

Sync run writes a file

  1. litellm.agent(Harness.CLAUDE_CODE, "Create a file named hello.txt whose entire content is the single word parity. Then reply with exactly DONE.", sandbox=sandbox.local(tmp), model="anthropic/claude-haiku-4-5")
  2. Output: {"stop_reason": "done", "text": "DONE", "hello.txt": "parity", "files": ["hello.txt"], "input_tokens>0": true, "output_tokens>0": true, "cost>0": true}

Async stream

  1. async for ev in litellm.aagent(Harness.CLAUDE_CODE, "Reply with exactly the word pong and nothing else.", ..., stream=True)
  2. Output: {"event_types": ["Done", "Text"], "last_event": "Done", "done_count": 1}

Sync call inside a running loop

  1. litellm.agent(...) called from inside asyncio.run(...)
  2. Output: RuntimeError: litellm.agent() cannot be called from a running event loop; use await litellm.a...

After (3f71c52)

Sync run writes a file

  1. Same call as Before
  2. Output: {"stop_reason": "done", "text": "DONE.", "hello.txt": "parity", "files": ["hello.txt"], "input_tokens>0": true, "output_tokens>0": true, "cost>0": true}

Async stream

  1. Same call as Before
  2. Output: {"event_types": ["Done", "Text"], "last_event": "Done", "done_count": 1}

Sync call inside a running loop

  1. Same call as Before
  2. Output: RuntimeError: litellm.agent() cannot be called from a running event loop; use await litellm.a...
  • 3f71c52 passes /audit (skipped: no product code on a request path, comment removals plus one uncalled private method)

Type

Refactoring

Caveats (if any)

Low

  • Docker sandbox and Deep Agents legs not run live; their diffs are comment-only

  • Assumes nothing outside the repo calls private _LoopThread.in_loop_thread

  • 3f71c52 passes /live-pr-risk

Link to Devin session: https://app.devin.ai/sessions/cfca9cd44fd4415384fc1dd926e0ec7b
Open in Devin Desktop: https://app.devin.ai/desktop/session/cfca9cd44fd4415384fc1dd926e0ec7b?variant=devin


Note

Low Risk
Comment-only edits plus removal of an uncalled private method; harness runtime behavior should be unchanged.

Overview
This PR is comment and dead-code cleanup in the new harness / litellm.agent() stack, with no intended behavior change.

It strips decorative section banners (# ---- / # -- name --) from harness modules (endpoint.py, runtime.py, sandbox/docker.py, deepagents harness adapters) and removes a few comments that only restated nearby code (lazy litellm.harness exports in litellm/__init__.py, injected HTTP client note on ModelEndpoint).

The only executable change is deleting the unused private _LoopThread.in_loop_thread helper from litellm/harness/sync.py; nothing in the repo referenced it.

Reviewed by Cursor Bugbot for commit 3f71c52. Bugbot is set up for automated code reviews on this repo. Configure here.

…n_loop_thread

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

devin-ai-integration Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration
devin-ai-integration Bot requested a review from a team October 2, 2026 08:00
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@codecov

codecov Bot commented Oct 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@greptile-apps

greptile-apps Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Low risk] Removes banner comments and dead code from harness modules.

The PR appears safe to merge; no actionable regression was identified.

Summary

This PR removes section-divider and restating comments across the harness modules, along with an unused private loop-thread method. No runtime behavior change was identified.

Reviews (1) · Last reviewed commit: "chore(harness): remove banner comments, ..."

@mateo-berri

Copy link
Copy Markdown
Contributor

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3f71c52. Configure here.

@codspeed

codspeed Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_techdebt_20261002 (3f71c52) with main (e32b258)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (7d50a31) during the generation of this report, so e32b258 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri merged commit 62a1b7f into main Oct 2, 2026
103 checks passed
@mateo-berri
mateo-berri deleted the litellm_techdebt_20261002 branch October 2, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants