feat: tool outputs metadata (#1155)

Summary:

Allows tools to output metadata. This is useful for evaluating tool
outputs, e.g. RAG tool will output document IDs, which can be used to
score recall.

Will need to make a similar change on the client side to support
ClientTool outputting metadata.

Test Plan:

LLAMA_STACK_CONFIG=fireworks pytest -s -v
tests/client-sdk/agents/test_agents.py
This commit is contained in:
ehhuang 2025-02-21 13:15:31 -08:00 committed by GitHub
parent 36162c8c82
commit 25fddccfd8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 141 additions and 28 deletions

View file

@ -165,6 +165,7 @@ class ToolResponse(BaseModel):
call_id: str
tool_name: Union[BuiltinTool, str]
content: InterleavedContent
metadata: Optional[Dict[str, Any]] = None
@field_validator("tool_name", mode="before")
@classmethod

View file

@ -26,6 +26,7 @@ class RAGDocument(BaseModel):
@json_schema_type
class RAGQueryResult(BaseModel):
content: Optional[InterleavedContent] = None
metadata: Dict[str, Any] = Field(default_factory=dict)
@json_schema_type

View file

@ -72,6 +72,7 @@ class ToolInvocationResult(BaseModel):
content: InterleavedContent
error_message: Optional[str] = None
error_code: Optional[int] = None
metadata: Optional[Dict[str, Any]] = None
class ToolStore(Protocol):