Repository navigation
chore(harness): remove banner comments, restating comments and dead in_loop_thread - #44161
Conversation
…n_loop_thread Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
|
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
|
bugbot run |
There was a problem hiding this comment.
✅ 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.
TLDR
Problem this solves:
How it solves it:
_LoopThread.in_loop_threadmethodUser Flow
Before: a developer runs Claude Code through
litellm.agent()on an Anthropic model, and it workslitellm.agent(Harness.CLAUDE_CODE, "create hello.txt ...", sandbox=sandbox.local(dir), model="anthropic/claude-haiku-4-5")hello.txt, and the Result reports stop reasondone, the file change, token usage and a non-zero costlitellm.aagent(..., stream=True)streams Text events and ends with one Done eventlitellm.agent()from inside a running event loop raises the "use await litellm.aagent" errorAfter: the same developer sees exactly the same results, since only unused code and comments are gone
litellm.agent(Harness.CLAUDE_CODE, "create hello.txt ...", sandbox=sandbox.local(dir), model="anthropic/claude-haiku-4-5")hello.txt, and the Result reports stop reasondone, the file change, token usage and a non-zero costlitellm.aagent(..., stream=True)streams Text events and ends with one Done eventlitellm.agent()from inside a running event loop raises the "use await litellm.aagent" errorFindings (run 2026-10-02, window 2026-10-01 07:45 UTC to 2026-10-02 07:45 UTC)
# ----/# -- name --section banners inlitellm/harness/endpoint.py,litellm/harness/runtime.py,litellm/harness/sandbox/docker.py,litellm/llms/deepagents/harness/transformation.pyandlitellm/llms/deepagents/harness/sandbox_backend.py. None is business logic, a tool directive, or a linked TODO. Deleted_LoopThread.in_loop_threadinlitellm/harness/sync.py, which nothing inlitellm/,enterprise/ortests/calls. Deleted# Injected client (tests); production uses LiteLLM's shared cached client.inModelEndpoint.__init__, which repeats the_gateway_clientdocstring. Deletedlitellm/__init__.pythat restate_AGENT_EXPORTSand the lazylitellm.harnessbranch of__getattr__. DeletedNothing was absorbed: no other
litellm_techdebt_PR was open. No budget file movedDeliberately left alone
Any,dict[str, Any]andmutable-okuses acrosslitellm/harness/and the fourlitellm/llms/*/harness/adapters (feat: add litellm.agent() to run claude code, codex, opencode and deep agents through the ai gateway #43885) sit on Claude Code, Codex, OpenCode and LangGraph event and config payloads; typing them needs schema models per runtime, too wide for a same-day cleanupgetattr(record, "tag", None)andgetattr(record, entity_id_field, None)incommon_daily_activity.pywere only re-annotated by refactor(repositories): daily activity repository with centralized bounded usage queries #43398, not added, so they are out of the window# noqa: C901onvalidate_resolved_virtual_key(d9f7324, feat(lens): track worker spend through virtual keys #43989) names its reason, and splitting it would risk the order of authorization checks# pyright: ignore[...]lines inredis_batch.py,shadow_eval_logger.pyand the TypeSafe guardrail each name the rule and an untyped upstream APIapp.stateand route-list writes in_lazy_features.pyare how Starlette routing works and are not fixable in placeScreenshots / Proof of Fix
Parity A/B through the real end-user client: the same script calls
litellm.agent()andlitellm.aagent()with Claude Code 2.1.287 (installed withnpm install -g @anthropic-ai/claude-code) on realanthropic/claude-haiku-4-5, once from a worktree at the merge base and once from a worktree at the tip, each run assertinglitellm.__file__resolves inside its worktree. Model text can differ by punctuation between runs; everything else must matchBefore (7d50a31)
Sync run writes a file
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"){"stop_reason": "done", "text": "DONE", "hello.txt": "parity", "files": ["hello.txt"], "input_tokens>0": true, "output_tokens>0": true, "cost>0": true}Async stream
async for ev in litellm.aagent(Harness.CLAUDE_CODE, "Reply with exactly the word pong and nothing else.", ..., stream=True){"event_types": ["Done", "Text"], "last_event": "Done", "done_count": 1}Sync call inside a running loop
litellm.agent(...)called from insideasyncio.run(...)RuntimeError: litellm.agent() cannot be called from a running event loop; use await litellm.a...After (3f71c52)
Sync run writes a file
{"stop_reason": "done", "text": "DONE.", "hello.txt": "parity", "files": ["hello.txt"], "input_tokens>0": true, "output_tokens>0": true, "cost>0": true}Async stream
{"event_types": ["Done", "Text"], "last_event": "Done", "done_count": 1}Sync call inside a running loop
RuntimeError: litellm.agent() cannot be called from a running event loop; use await litellm.a...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_thread3f71c52 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 (lazylitellm.harnessexports inlitellm/__init__.py, injected HTTP client note onModelEndpoint).The only executable change is deleting the unused private
_LoopThread.in_loop_threadhelper fromlitellm/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.