AI-Engineer-Foundation / agent-protocol

Common interface for interacting with AI agents. The protocol is tech stack agnostic - you can use it with any framework for building agents.

Home Page:https://agentprotocol.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proposal: Langchain Integration

jondwillis opened this issue · comments

commented

Objective:

The primary advantage to be gained from integrating with Langchain is for Agent Protocol exposure/advocacy. Langchain docs and repos get a decent chunk of traffic! There is also greater potential for simple and quick interop between projects that adopt Langchain and/or the Agent Protocol already.

Additionally, the proposed Agent and AgentExecutor could be used as a reference implementation.

Background:

LangChain consists of a Python and Typescript library. There are also some other newer applications in the ecosystem such as LangSmith and LangServe. LangChain is a commonly used library that has built-in agents already.

Proposed:

TL;DR: Implement something like AgentProtocolAgent and AgentProtocolAgentExecutor, which would take an Agent Protocol API-compliant base URL. After there is a PR open for that, we can then evaluate if some other abstractions like Tool, Chain, Retriever, etc., would be worth implementing as well.

We can probably get by with following: https://github.com/langchain-ai/langchainjs/blob/main/.github/contributing/INTEGRATIONS.md
Otherwise, we contact and work with the LangChain TS and Python maintainers so that we can have a high chance of success for having a set of pull requests merged into the upstream Langchain repos. The pull requests should consider integrating with the Agent Protocol in the following ways:

  • An Agent that works by consuming Agent Protocol endpoints. This could work by extending or passing in a new parameter to the agent executor initializer functions.

  • A Tool that works by calling Agent Protocol endpoints.

  • A Retriever that gets the result of a task or otherwise consumes Agent Protocol endpoints.

  • Add documentation (there are many Integrations docs already to use as examples!) so that discoverability is improved.

Examples:

TBD

Discussion Points:

Are the proposed abstractions the best to start with and sufficient?

I am happy to try to work on this initiative, but I also have limited time and would be more effective working on the Typescript portion.

First of all, excited that this proposal is in progress.

I think the abstractions make sense conceptually, but I'm having trouble understanding exactly how you would adapt a Langchain agent to the protocol.

Given that there are multiple agents and chains available in Langchain with many permutations for combining them, it'd be great to understand how an existing agent can become compliant and how that determination can be verified.

Some concrete examples detailing this would be fantastic - I'd be happy to contribute some after getting a better sense of what you're thinking.

commented

First of all, excited that this proposal is in progress.

I think the abstractions make sense conceptually, but I'm having trouble understanding exactly how you would adapt a Langchain agent to the protocol.

Given that there are multiple agents and chains available in Langchain with many permutations for combining them, it'd be great to understand how an existing agent can become compliant and how that determination can be verified.

Some concrete examples detailing this would be fantastic - I'd be happy to contribute some after getting a better sense of what you're thinking.

I am working on this, and will link a few prototypes soon. After some basic research and discussion, the most clear path in my understand would be to write a custom AgentExecutor+Agent. (unfortunately AgentProtocolAgentExecutor, and AgentProtocolAgent do not exactly roll off the tongue 👅.) The primary new input to these would an Agent Protocol API-compliant base URL. This would basically serve as a reference implementation, and then I will consider exposing the Agent Protocol in other ways (Tools, Retrievers, Chains).

I may be oversimplifying or missing some details, so let me know if you have any specific suggestions or use-cases you want to support @davidzshi

Given that there are multiple agents and chains available in Langchain with many permutations for combining them, it'd be great to understand how an existing agent can become compliant and how that determination can be verified.

This is how you can verify:

$ URL=http://127.0.0.1:8000 bash -c "$(curl -fsSL https://raw.githubusercontent.com/AI-Engineers-Foundation/agent-protocol/main/testing_suite/test.sh)"

where http://127.0.0.1:8000 is where your agent is running, and accepting REST calls that are compliant with the protocol.

Got it! Thanks @jondwillis @hackgoofer, that's helpful context. Looking forward to reading more about the reference implementation when it's ready.

I'm primarily interested in the potential of interoperable Langchain agents. In practice, this means that for a specific field, a number of specialist agents can be created and then called upon to solve complex problems. In Langchain, this would look like leveraging agents as tools, but what excites me most about Agent Protocol is the potential for multi-agent systems that are unaffiliated. If one generalist agent is able to, using the standardization of queries and responses, access the specialized skills of a specialist agent, it opens up an entire world of possibilities.