Mirascope
Build. Observe. Iterate. Ship.
The complete toolkit for AI engineers
librarian
Mirascope
from mirascope import llm, ops
@llm.tool
def library(genre: str) -> list[str]:
"""Search library for books by genre."""
books = {
"sci-fi": ["Dune", "Foundation"],
"fantasy": ["The Name of the Wind", "The Way of Kings"],
}
return books.get(genre, [])
@ops.version() # Automatic versioning, tracing, and cost tracking
@llm.call(
"openai/gpt-5.2",
tools=[library],
thinking={"include_thoughts": True},
)
def librarian(query: str) -> str:
return query
# Agent Loop
response = librarian("Recommend some sci-fi books")
while response.tool_calls:
tool_outputs = response.execute_tools()
response = response.resume(tool_outputs)
print(response.text())Traces
Version
Time
In
Out
Cost
2
1 min ago
156
89
$0.0024
2
2 mins ago
142
67
$0.0019
1
1 hr ago
138
52
$0.0016
Messages
Recommend some sci-fi books
in: {"genre":"sci-fi"}
out: ["Dune","Foundation"]
Based on our library, I'd recommend these sci-fi classics:
- Dune by Frank Herbert - An epic tale of politics and survival
- Foundation by Isaac Asimov - A groundbreaking series about civilization