RAG-вопрос
Explain how LLM tool/function calling works end to end: tool schema in the prompt, model output, real tool execution and final user response.
Ответить самому
Сначала сформулируйте ответ как на собеседовании, затем откройте разбор и оцените себя.
Короткий ответ
The orchestration layer exposes tool schemas to the model, the model emits a structured tool call, the runtime parses and executes the real function, then appends the tool result back to context so the model can answer the user.
Полный разбор
Tool calling is not the model magically accessing external systems. The application or provider runtime first tells the model what tools exist: names, descriptions, argument schemas and rules for how to emit calls. This may be represented as provider-native tool metadata or as prompt instructions plus a special output format.
When the user request requires external action, the model emits a structured tool call such as a function name plus JSON arguments. The orchestration layer validates the schema, parses the arguments and calls the real function or API. For a weather example, the LLM does not fetch weather itself; the runtime calls the weather API.
The tool result is then added back into the conversation as a tool message or equivalent context item. The model receives that result and produces the final natural-language answer. Production systems also need retries, validation, authorization, rate limits, tool-result truncation, logging and safeguards against prompt injection through tool outputs.
Теория
The model chooses and formats tool calls; the surrounding runtime executes tools and feeds results back into the model context.
Типичные ошибки
- Describe tools as if the LLM directly calls APIs by itself.
- Skip argument validation and error handling.
- Forget the second model call that converts tool results into the final answer.
Как отвечать на собеседовании
- Draw the loop: user message -> model tool call -> runtime execution -> tool result -> final model response.
- Mention both schema prompting and real execution; interviewers often probe that boundary.