-
Notifications
You must be signed in to change notification settings - Fork 139
Revise README for Agent Stack Server SDK #1711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
28186ca
cf345a4
8db6d7d
2c283eb
80e82d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,45 +1,120 @@ | ||||||||
| # Agent Stack SDK | ||||||||
| # Agent Stack Server SDK | ||||||||
|
|
||||||||
| ## Examples | ||||||||
| Python SDK for deploying agents to Agent Stack infrastructure. | ||||||||
|
|
||||||||
| The examples connect to the Agent Stack for LLM inteference. | ||||||||
| [](https://pypi.org/project/agentstack-sdk/) | ||||||||
| [](https://opensource.org/licenses/Apache-2.0) | ||||||||
| [](https://lfaidata.foundation/projects/) | ||||||||
|
|
||||||||
| Run using: | ||||||||
| ## Overview | ||||||||
|
|
||||||||
| The `agentstack-sdk` provides Python utilities for wrapping agents built with any framework (LangChain, CrewAI, BeeAI Framework, etc.) for deployment on Agent Stack. It handles the A2A (Agent-to-Agent) protocol implementation, platform service integration, and runtime requirements so you can focus on agent logic. | ||||||||
|
|
||||||||
| ## Key Features | ||||||||
|
|
||||||||
| - **Framework-Agnostic Deployment** - Wrap agents from any framework for Agent Stack deployment | ||||||||
| - **A2A Protocol Support** - Automatic handling of Agent-to-Agent communication | ||||||||
| - **Platform Service Integration** - Connect to Agent Stack's managed LLM, embedding, file storage, and vector store services | ||||||||
| - **Agent Wrapper** - Opinionated utilities with `yield` semantics and autowired services | ||||||||
| - **Context Storage** - Manage data associated with conversation contexts | ||||||||
|
|
||||||||
| ## Installation | ||||||||
|
|
||||||||
| ```bash | ||||||||
| uv run examples/agent.py | ||||||||
| uv add agentstack-sdk | ||||||||
| ``` | ||||||||
|
|
||||||||
| Connect to the agent using the CLI: | ||||||||
| ## Quickstart | ||||||||
|
|
||||||||
| ```python | ||||||||
| import os | ||||||||
| from a2a.types import AgentSkill, Message | ||||||||
| from agentstack_sdk.server import Server | ||||||||
| from agentstack_sdk.server.context import RunContext | ||||||||
| from agentstack_sdk.server.store.platform_context_store import PlatformContextStore | ||||||||
|
|
||||||||
| # Initialize server | ||||||||
| server = Server() | ||||||||
|
|
||||||||
| # Define your agent | ||||||||
| @server.agent( | ||||||||
| name="My Agent", | ||||||||
| skills=[ | ||||||||
| AgentSkill( | ||||||||
| id="my-agent-skill", | ||||||||
| name="My Agent", | ||||||||
| description="Agent description here", | ||||||||
| tags=["Chat"], | ||||||||
| examples=["Example query 1", "Example query 2"] | ||||||||
| ) | ||||||||
| ], | ||||||||
| ) | ||||||||
| async def my_agent( | ||||||||
| input: Message, | ||||||||
| context: RunContext, | ||||||||
| ): | ||||||||
| """Your agent logic here""" | ||||||||
|
|
||||||||
| # Store incoming message | ||||||||
| await context.store(input) | ||||||||
|
|
||||||||
| # Extract user message | ||||||||
| user_msg = "".join( | ||||||||
| part.root.text for part in input.parts | ||||||||
| if part.root.kind == "text" | ||||||||
| ) | ||||||||
|
|
||||||||
| # Process and yield response | ||||||||
| response_text = f"You said: {user_msg}" | ||||||||
| yield response_text | ||||||||
|
|
||||||||
| # Store response in context | ||||||||
| from agentstack_sdk.a2a.types import AgentMessage | ||||||||
| await context.store(AgentMessage(text=response_text)) | ||||||||
|
||||||||
| from agentstack_sdk.a2a.types import AgentMessage | |
| await context.store(AgentMessage(text=response_text)) | |
| await context.store(AgentMessage(text=response_text)) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The os.getenv function's default value must be a string. Providing an integer 8000 will cause a TypeError if the PORT environment variable is not set. The default value should be a string, "8000", which is then converted to an integer.
| port=int(os.getenv("PORT", 8000)), | |
| port=int(os.getenv("PORT", "8000")), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
my_agentfunction is an async generator, but it lacks a return type hint. Adding a type hint makes the function's contract explicit, improving readability and enabling better static analysis. You'll need to importAsyncGeneratorfromcollections.abcat the top of the file.