Problem: “reply in JSON” in the prompt = no guarantee.
Solution: a tool never executed, which only serves to mold the output:
resp = client.messages.create(
model=MODEL, max_tokens=1024,
tools=[extraction_tool],
tool_choice={"type": "tool", "name": "record_ticket_analysis"},
messages=[{"role": "user", "content": f"Analyse :\n{ticket}"}],
)
data = next(b for b in resp.content
if b.type == "tool_use").input
No tool_result to return: one-way call.