Accept prebuilt agent objects and let agents declare dependencies - #48
Closed
nickhuo wants to merge 1 commit into
Closed
Accept prebuilt agent objects and let agents declare dependencies#48nickhuo wants to merge 1 commit into
nickhuo wants to merge 1 commit into
Conversation
Two limits currently stop mainstream agent projects from running on Ventis. Each is a hardcoded assumption with no way to override it. _load_agent did getattr(module, agent_name) followed by agent_class(). That requires the yaml's agent.name to point at a class with a no-arg constructor. LangGraph exports a compiled graph, LCEL exports a RunnableSequence, CrewAI exports a Crew -- all instances. Calling one raises TypeError, which _load_agent swallows, so the replica comes up, reports healthy, and answers "No agent loaded" on every request. The only way through was an adapter class whose entire job was to hold a reference and forward one call. It now calls the target only when it is a class. Classes behave exactly as before, so every existing example is unaffected. Two things follow: a project can name its exported graph directly and need no adapter at all, and a project can export an already-configured instance, which is the first place configuration has had to live other than environment variables read inside __init__. generate_docker and generate_workflow_docker wrote a fixed requirements.txt with no hook of any kind, so nothing outside grpcio, redis, pyyaml, boto3, yfinance, psutil, ipdb and ipython could reach an agent image -- langchain, langgraph and crewai included. Agent and workflow entries in global_controller.yaml now take a `requirements` list, appended to the runtime's own. Entries naming a runtime dependency are dropped rather than added, so a project cannot repin something the controller has to run against. Verified against a LangGraph email assistant: with agent.name pointing at the compiled graph and its dependencies declared, the port is one 8-line workflow and two yaml files, no adapter, and langchain, langgraph, langchain-openai, dotenv and html2text all import inside the built image. Tests cover both paths, including the constructor-argument case and the repinning guard. The three pre-existing failures in test_telemetry_logging.py reproduce on unmodified main.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft. Two changes that let a LangChain / LangGraph / CrewAI project run on Ventis without being rewritten.
1.
_load_agentno longer requires a classThis requires
agent.nameto be a class with a no-arg constructor. What the frameworks actually export is an object:graph = builder.compile()CompiledStateGraphchain = prompt | llm | parserRunnableSequencecrew = Crew(agents=..., tasks=...)CrewCalling one raises
TypeError,_load_agentswallows it, and every request answers"No agent loaded". The only way through was an adapter class that exists purely to hold a reference and forward one call.Now:
Two consequences:
agent_class()takes no arguments, so a configured agent previously had nowhere to receive its config except environment variables read inside__init__. A project can now exportagent = MyAgent(model="gpt-4.1")and Ventis uses it as-is.Backward compatible:
isinstance(target, type)is true for classes, so all four existing examples take the same path as before.2. Agents and workflows can declare dependencies
generate_dockerandgenerate_workflow_dockereach wrote a fixedrequirements.txt(hard code)Declared entries are appended to the runtime's own list. An entry naming a runtime dependency is dropped rather than appended, so a project cannot repin something the controller has to run against (
redis>=5.0is ignored, not added).