Skip to content

fix(agent): harden harness profile registration and clarify subagent VFS tooling#51

Merged
barredterra merged 3 commits into
developfrom
deepagent-fixes
Jul 13, 2026
Merged

fix(agent): harden harness profile registration and clarify subagent VFS tooling#51
barredterra merged 3 commits into
developfrom
deepagent-fixes

Conversation

@barredterra

@barredterra barredterra commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

  • Guard the Deep Agents harness profile registration with a threading.Lock so concurrent agent runner constructions in one process cannot both register, eliminating a redundant duplicate-register merge and its warning log.
  • Document why the source-code-analyzer subagent is declared with tools: []: Deep Agents injects FilesystemMiddleware (and the read-only VFS tools ls, read_file, glob, grep) into every subagent stack regardless of the tools field; the empty list only prevents inheriting the parent's mutation tools.
  • Declare langchain, langchain-core, and langgraph as direct, range-pinned dependencies (previously only transitive via deepagents/langchain-openai) so an incompatible resolver resolution surfaces at install time instead of breaking imports.

Test plan

  • Edited files parse; no linter errors.
  • Module imports and double-registration of the harness profile is a no-op.
  • Verify the agent still boots and the source-code-analyzer subagent can read files from /source/ on a dev site.

Concurrent ask_alyfAgentRunner constructions in one process could both
observe the registered flag as false and call register_harness_profile
twice. Registration merges on duplicate keys, so an identical double
register was functionally safe but logged a warning and did a redundant
merge. Guard the check-then-set with a threading.Lock.
The source-code-analyzer subagent is declared with tools: [], which
looks like it receives no tools at all. Deep Agents always injects
FilesystemMiddleware (and thus the read-only VFS tools ls, read_file,
glob, grep) into every subagent stack regardless of the tools field;
the tools list only controls extra tools inherited from the parent.
Document this so the empty list is not mistaken for a bug.
agent.py and history.py import from langchain and langchain_core, and
langgraph underpins the deepagents runtime, but all three arrived only
as transitive dependencies of deepagents and langchain-openai. A
downstream resolver could pull a compatible-but-different version and
break the imports with no install-time signal. Pin them to the ranges
required by the pinned deepagents/langchain-openai versions.
@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Both changes are safe to merge: the lock-based registration is correct and the new dependency bounds match what was already being pulled transitively.

The threading change is a well-scoped, low-risk fix to a real but harmless race (previously the duplicate register only caused a warning log). The dependency additions are purely declarative and don't change any runtime behaviour — they only surface resolver conflicts earlier. No functional logic is altered, and the VFS tool injection comment accurately reflects the Deep Agents library's documented behaviour.

No files require special attention; the only open item is the manual test from the PR checklist (verifying the source-code-analyzer subagent can read /source/ on a dev site), which is a runtime integration concern outside the diff.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant T1 as Thread 1 (gunicorn/RQ)
    participant T2 as Thread 2 (gunicorn/RQ)
    participant Lock as _ASK_ALYF_PROFILE_LOCK
    participant Flag as _ASK_ALYF_PROFILE_REGISTERED
    participant DA as register_harness_profile()

    T1->>Lock: acquire
    T2->>Lock: acquire (blocks)
    Lock-->>T1: acquired
    T1->>Flag: check (False)
    T1->>DA: register_harness_profile("openai", profile)
    DA-->>T1: ok
    T1->>Flag: set True
    T1->>Lock: release
    Lock-->>T2: acquired
    T2->>Flag: check (True)
    T2->>Lock: release (return early - no double-register)
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant T1 as Thread 1 (gunicorn/RQ)
    participant T2 as Thread 2 (gunicorn/RQ)
    participant Lock as _ASK_ALYF_PROFILE_LOCK
    participant Flag as _ASK_ALYF_PROFILE_REGISTERED
    participant DA as register_harness_profile()

    T1->>Lock: acquire
    T2->>Lock: acquire (blocks)
    Lock-->>T1: acquired
    T1->>Flag: check (False)
    T1->>DA: register_harness_profile("openai", profile)
    DA-->>T1: ok
    T1->>Flag: set True
    T1->>Lock: release
    Lock-->>T2: acquired
    T2->>Flag: check (True)
    T2->>Lock: release (return early - no double-register)
Loading

Reviews (1): Last reviewed commit: "chore(deps): declare langchain, langchai..." | Re-trigger Greptile

@barredterra
barredterra merged commit 04435a1 into develop Jul 13, 2026
5 checks passed
@barredterra
barredterra deleted the deepagent-fixes branch July 13, 2026 02:29
@barredterra
barredterra restored the deepagent-fixes branch July 13, 2026 02:34
@barredterra

Copy link
Copy Markdown
Member Author

Added a follow-up cleanup commit: removed the five orphaned code-search toolset wrapper methods (search_code, read_code_file, ls, find, grep) that were no longer registered as agent tools after the move to the source-code-analyzer subagent. The underlying tools.* functions remain. All 34 code-tool tests pass.

@barredterra
barredterra deleted the deepagent-fixes branch July 13, 2026 02:35
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.

1 participant