Skip to content

feat: move from mozilla any-agent to langchain deepagents (backport #44)#49

Merged
barredterra merged 5 commits into
version-16from
mergify/bp/version-16/pr-44
Jul 13, 2026
Merged

feat: move from mozilla any-agent to langchain deepagents (backport #44)#49
barredterra merged 5 commits into
version-16from
mergify/bp/version-16/pr-44

Conversation

@mergify

@mergify mergify Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

This is an automatic backport of pull request #44 done by [Mergify](https://mergify.com).

@greptile-apps

greptile-apps Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The migration is architecturally sound and the single non-blocking observation (asyncio.run inside a sync tool) is safe under LangGraph's current thread-pool dispatch model.

This is a large but well-contained framework swap. The harness profile lock, explicit VFS deny permissions, and typed subagent response schemas are all in place. The only observation worth noting is the asyncio.run() + lazy import in extract_document_data, which works today but relies on LangGraph always dispatching sync tools through run_in_executor rather than inline. No data-loss, auth bypass, or schema/migration concerns are present.

ask_alyf/ask_alyf/toolset.py — specifically the extract_document_data method's asyncio.run() bridge pattern.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant FE as Frontend
    participant API as api.py
    participant RM as run_message()
    participant Runner as ask_alyfAgentRunner
    participant DA as Deep Agents<br/>(create_deep_agent)
    participant TS as ask_alyfToolset
    participant SA as Subagents<br/>(source-code-analyzer / document-planner)
    participant VFS as CompositeBackend<br/>(/workspace/ /source/ /attachments/)

    FE->>API: POST /ask
    API->>RM: run_message(conversation_name, message, mode, request_context, history)
    RM->>Runner: ask_alyfAgentRunner(runtime)
    Runner->>Runner: _ensure_ask_alyf_harness_profile() [once per process, locked]
    Runner->>Runner: build_chat_model(settings)
    Runner->>VFS: build_ask_alyf_backend(app_roots)
    Runner->>DA: create_deep_agent(model, tools, system_prompt, backend, subagents, permissions)
    Runner->>Runner: build_input_messages(history + new HumanMessage)
    Runner->>DA: "agent.invoke({messages})"
    DA->>TS: tool call (get_list / get_meta / insert / ...)
    TS-->>DA: result
    DA->>SA: task tool → subagent invocation
    SA->>VFS: read-only ops (/source/ or /attachments/)
    VFS-->>SA: FileData / LsResult / GrepResult
    SA-->>DA: SourceCodeAnalysisResult / DocumentPlannerResult
    DA-->>Runner: "{messages: [...AIMessage]}"
    Runner-->>RM: "{response, pending_operations, document_extractions, attached_files}"
    RM-->>API: dict
    API-->>FE: JSON response
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 FE as Frontend
    participant API as api.py
    participant RM as run_message()
    participant Runner as ask_alyfAgentRunner
    participant DA as Deep Agents<br/>(create_deep_agent)
    participant TS as ask_alyfToolset
    participant SA as Subagents<br/>(source-code-analyzer / document-planner)
    participant VFS as CompositeBackend<br/>(/workspace/ /source/ /attachments/)

    FE->>API: POST /ask
    API->>RM: run_message(conversation_name, message, mode, request_context, history)
    RM->>Runner: ask_alyfAgentRunner(runtime)
    Runner->>Runner: _ensure_ask_alyf_harness_profile() [once per process, locked]
    Runner->>Runner: build_chat_model(settings)
    Runner->>VFS: build_ask_alyf_backend(app_roots)
    Runner->>DA: create_deep_agent(model, tools, system_prompt, backend, subagents, permissions)
    Runner->>Runner: build_input_messages(history + new HumanMessage)
    Runner->>DA: "agent.invoke({messages})"
    DA->>TS: tool call (get_list / get_meta / insert / ...)
    TS-->>DA: result
    DA->>SA: task tool → subagent invocation
    SA->>VFS: read-only ops (/source/ or /attachments/)
    VFS-->>SA: FileData / LsResult / GrepResult
    SA-->>DA: SourceCodeAnalysisResult / DocumentPlannerResult
    DA-->>Runner: "{messages: [...AIMessage]}"
    Runner-->>RM: "{response, pending_operations, document_extractions, attached_files}"
    RM-->>API: dict
    API-->>FE: JSON response
Loading

Reviews (3): Last reviewed commit: "refactor(toolset): remove orphaned code-..." | Re-trigger Greptile

Comment thread ask_alyf/ask_alyf/agent.py
Comment thread ask_alyf/ask_alyf/agent.py Outdated
Comment thread pyproject.toml
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.
@barredterra

Copy link
Copy Markdown
Member

Cherry-picked the follow-up fixes from the develop PR onto this backport branch: harness profile registration lock, subagent VFS tooling clarification, and explicit langchain/langchain-core/langgraph dependency declarations.

Drop the five ask_alyfToolset wrappers search_code, read_code_file,
ls, find, and grep. Code search now runs through the source-code-analyzer
subagent against the /source/ virtual mount, so these wrappers were no
longer registered as agent tools and had no callers. The underlying
tools.* functions remain, still used by tests and the VFS backend.
@barredterra

Copy link
Copy Markdown
Member

Cherry-picked a follow-up cleanup onto this backport branch: 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.

@barredterra

Copy link
Copy Markdown
Member

Note: the cleanup commit on this backport branch is also being PR'd against develop separately (the develop PR for the prior fixes merged before the cleanup could be added to it), so develop and the backports stay in sync.

@barredterra
barredterra merged commit 3e2c94b into version-16 Jul 13, 2026
5 checks passed
@barredterra
barredterra deleted the mergify/bp/version-16/pr-44 branch July 13, 2026 02:55
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