Define a local tool¶
This example requires only the installed SDK. It builds an Agent with a typed tool, prints its schema, and invokes it locally. It does not connect to a runtime or model.
The output contains the schema and result 2. There are no resources to clean up. To make a tool available to a live agent, configure a suitable runtime and tool host; local invocation here does not register one.
"""Define and exercise a typed Agent tool locally, without a runtime or model."""
import asyncio
import json
from edith_hermes import Agent, tool
@tool
def word_count(text: str) -> int:
"""Count whitespace-separated words."""
return len(text.split())
async def main():
agent = Agent("Example", tools=[word_count])
print(
json.dumps(
{
"tool": agent.tools[0].definition(),
"result": await agent.tools[0].invoke({"text": "hello Hermes"}),
},
indent=2,
)
)
if __name__ == "__main__":
asyncio.run(main())