Overseas access: www.kdjingpai.com
Bookmark Us
Current Position:fig. beginning " Course materials

12 - Factor Agents 4. Tools are just structured outputs

2025-07-22 46

The tool need not be complex. At its core, it is simply structured output from your Large Language Model (LLM) for triggering deterministic code.

12 - Factor Agents 4. Tools are just structured outputs - 1

For example, suppose you have two tools CreateIssue cap (a poem) SearchIssues. Asking a Large Language Model (LLM) to "use one of multiple tools" is really asking it to output a JSON that we can parse as an object representing those tools.

class Issue:
title: str
description: str
team_id: str
assignee_id: str
class CreateIssue:
intent: "create_issue"
issue: Issue
class SearchIssues:
intent: "search_issues"
query: str
what_youre_looking_for: str

The pattern is simple:

  1. Large Language Model (LLM) Output Structured JSON
  2. Deterministic code performs the appropriate action (e.g. calling an external API)
  3. Capture results and feed back into context

This creates a clear separation between the decisions of the Large Language Model (LLM) and the operations of your application. the LLM decides what to do, but your code controls how to do it. Just because the LLM "calls a tool" doesn't mean you have to execute a particular function the same way every time.

If you remember our switch statement from above.

if nextStep.intent == 'create_payment_link':
stripe.paymentlinks.create(nextStep.parameters)
return # 或者任何你想要的操作,见下文
elif nextStep.intent == 'wait_for_a_while': 
# 做一些单子 (monadic) 操作之类的
else: #... 模型没有调用我们已知的工具
# 做些别的事情

take note ofThere has been a lot of discussion about the advantages and performance tradeoffs between "plain prompting", "tool calling", and "JSON mode". "There has been a lot of discussion about the benefits and performance tradeoffs of plain prompting, tool calling, and JSON mode. We'll provide links to some related resources soon, but we won't go into depth here. See also Hints vs JSON Schema vs Function Calls vs Constraint Generation vs SAP,When should I use function calls, structured output, or JSON patterns? cap (a poem) OpenAI JSON vs Function CallsThe

The "next step" may not be as atomic as "run a pure function and return the result". When you think of a "tool call" as just the model outputting a JSON that describes what the deterministic code should do, you unlock a great deal of flexibility. Compare this to the Element 8: Own your control flow Combined.

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

inbox

Contact Us

Top

en_USEnglish