feat: add AgentCard for self-describing agent capabilities#296
Open
prassanna-ravishankar wants to merge 6 commits intomainfrom
Open
feat: add AgentCard for self-describing agent capabilities#296prassanna-ravishankar wants to merge 6 commits intomainfrom
prassanna-ravishankar wants to merge 6 commits intomainfrom
Conversation
…ecorators in tests
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.
Summary
AgentCardmodel to agentex-sdk, enabling agents to describe their capabilities, lifecycle, and communication contract during registrationregistration_metadataJSONB field — no server changes requiredWhat changed
lib/types/agent_card.py—AgentCard,AgentLifecycle,LifecycleStatemodels withfrom_state_machine()constructor andextract_literal_values()utilityStateWorkflow— Added optionaldescription,waits_for_input,accepts,transitionsclass attrs (all default to empty, no impact on existing agents)StateMachine— Addedget_lifecycle()method to introspect registered workflowsFastACP.create()— Accepts optionalagent_cardparamregister_agent()— Merges agent card intoregistration_metadata["agent_card"]Backward compatibility
registration_metadatapreservesNonewhen no agent_card or build info is present (existing behavior unchanged)_agent_cardfrom BaseACPServerUsage
Stateful agent:
Simple agent:
Motivation
See design doc: agent-to-agent communication (OneEdge orchestrator ↔ specialized agents) requires a machine-readable contract per agent. Currently encoded as prose in LLM system prompts. Also enables TypeScript type codegen for frontend apps via
output_schema(JSON Schema from Pydantic models).🤖 Generated with Claude Code
Greptile Summary
Adds
AgentCard— a Pydantic model that lets agents describe their capabilities, lifecycle states, and communication contract during registration. The card is derived from existingStateWorkflowannotations and Pydantic models (not manually maintained config), and flows through the existingregistration_metadataJSONB field with no server-side changes required.AgentCard,AgentLifecycle,LifecycleStatemodels inagent_card.pywith two constructors:from_states()(from a raw states list) andfrom_state_machine()(from aStateMachineinstance)StateWorkflowgains optional class-level attributes (description,waits_for_input,accepts,transitions) with safe defaultsStateMachine.get_lifecycle()introspects registered workflows for card constructionFastACP.create()accepts optionalagent_cardparam, threaded through toregister_agent()which merges it intoregistration_metadataConfidence Score: 4/5
This PR is safe to merge — all new fields are optional with defaults, backward compatibility is preserved, and tests are thorough.
Well-structured additive feature with no breaking changes. All new attributes are optional. Comprehensive test coverage. One minor style concern about mutable class-level defaults in StateWorkflow (safe today but structurally fragile). Code duplication between from_states and from_state_machine is a minor concern but not a blocker.
src/agentex/lib/sdk/state_machine/state_workflow.py has mutable class-level list defaults that are safe today but could become a shared-state bug if future code mutates them in-place.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["FastACP.create(agent_card=card)"] --> B["Instance created<br/>(SyncACP / AsyncBaseACP / TemporalACP)"] B --> C["instance._agent_card = card"] C --> D["Lifespan startup"] D --> E["register_agent(env_vars, agent_card)"] E --> F{"agent_card is not None?"} F -- Yes --> G["card_data = agent_card.model_dump()"] G --> H["registration_metadata['agent_card'] = card_data"] F -- No --> I["registration_metadata = get_build_info()"] H --> J["POST /agents/register"] I --> J subgraph "AgentCard Construction" K["StateWorkflow subclasses<br/>(description, accepts, transitions)"] --> L["StateMachine.get_lifecycle()"] L --> M["AgentCard.from_state_machine()"] K --> N["State list + initial_state"] N --> O["AgentCard.from_states()"] endPrompt To Fix All With AI
Reviews (5): Last reviewed commit: "Add AgentCard.from_states() classmethod ..." | Re-trigger Greptile