# Kod jako akcja agenta (wywoływanie narzędzi z kodu)

EN: **Code as action (programmatic tool calling)** · id `codeact` · aliases: code actions, programmatic tool calling, kod jako akcja

Path: [AI Atlas](https://aiatlasgraph.com/llms.txt) › [Aplikacje LLM i agenci](https://aiatlasgraph.com/t/applications.md) › [Narzędzia i integracje](https://aiatlasgraph.com/t/tools.md) › Kod jako akcja agenta (wywoływanie narzędzi z kodu)

## Description

- PL: Wyrażanie akcji agenta jako wykonywalnego kodu (zwykle Pythona), który wywołuje narzędzia, steruje przepływem i filtruje wyniki przed powrotem do modelu.
- EN: Expressing agent actions as executable code (usually Python) that calls tools, controls flow and filters results before they return to the model.

## In one sentence

- PL: Zamiast wywoływać narzędzia po jednym, agent pisze krótki program, który sam je wywołuje, łączy wyniki i oddaje tylko podsumowanie.
- EN: Instead of calling tools one at a time, the agent writes a short program that calls them, combines the results and returns only a summary.

## Problem it solves

- PL: Zadanie wymagające dziesiątek wywołań narzędzi ciągnie się długo, a surowe wyniki zapychają pamięć rozmowy.
- EN: A task needing dozens of tool calls drags on, and raw results clog the conversation's memory.

## What it does

- PL: Przypomina napisanie makra w arkuszu zamiast klikania tej samej czynności sto razy.
- EN: It is like writing a spreadsheet macro instead of clicking the same action a hundred times.

## Everyday example

- PL: Asystent ma sprawdzić wydatki dwudziestu pracowników; pisze pętlę, która pobiera dane każdego, i pokazuje tylko osoby powyżej limitu.
- EN: An assistant must check twenty employees' expenses; it writes a loop that fetches each one and shows only those over the limit.

## This concerns you if you…

- PL: agent wykonuje długie serie podobnych wywołań narzędzi
- PL: chcesz zmniejszyć koszt i czas pracy agenta
- EN: have an agent making long series of similar tool calls
- EN: want to cut an agent's cost and running time

## Keywords

CodeAct · programmatic tool calling · CodeActInstruct · Python tool calling · self-debugging · executable actions

## How it works

- PL: Narzędzia są udostępnione jako funkcje w środowisku wykonawczym kodu. Model generuje skrypt z pętlami, warunkami i równoległymi wywołaniami; interpreter go wykonuje, a do kontekstu wraca tylko końcowy wynik lub błąd. Dzięki temu jedna akcja może zastąpić wiele rund wywołań, a model poprawia kod po komunikatach błędów.
- EN: Tools are exposed as functions inside a code-execution environment. The model writes a script with loops, conditions and parallel calls; the interpreter runs it and only the final output or error returns to context. One action can replace many call rounds, and the model fixes code after error messages.

## Limits

- PL: Wymaga bezpiecznej piaskownicy i dodaje narzut wykonywania kodu, więc nie opłaca się przy pojedynczych prostych wywołaniach. Gdy model musi rozważyć każdy wynik pośredni, ukrycie ich w kodzie szkodzi; błędy w skrypcie bywają trudniejsze do zauważenia niż błędne pojedyncze wywołanie.
- EN: It needs a secure sandbox and adds code-execution overhead, so it does not pay off for single simple calls. When the model must weigh every intermediate result, hiding them in code hurts; script bugs can be harder to spot than one bad call.

## Key terms

- PL: **przestrzeń akcji**: Zbiór wszystkich działań, jakie agent może wykonać w jednym kroku.
- PL: **wywołanie programowe**: Użycie narzędzia z wnętrza kodu zamiast bezpośredniego żądania modelu.
- EN: **action space**: The set of all actions an agent can take in one step.
- EN: **programmatic call**: Using a tool from inside code rather than via a direct model request.

## Know first

- [Wykonywanie kodu w piaskownicy (Sandboxed code execution for assistants)](https://aiatlasgraph.com/t/codeexecution.md)
- [ReAct: rozumowanie przeplatane z działaniem (ReAct (interleaved reasoning and acting))](https://aiatlasgraph.com/t/reactagents.md)

## Sources

- [Introducing advanced tool use on the Claude Developer Platform](<https://www.anthropic.com/engineering/advanced-tool-use>) `anthropic-advanced-tool-use-2025` · by Anthropic Engineering
- [Executable Code Actions Elicit Better LLM Agents](<https://arxiv.org/abs/2402.01030>) `wang-codeact-2024` · by Xingyao Wang, Yangyi Chen, Lifan Yuan, Yizhe Zhang, Yunzhu Li, Hao Peng, Heng Ji

---

AI Atlas revision 124 (2026-10-31) · HTML: https://aiatlasgraph.com/t/codeact · index: https://aiatlasgraph.com/llms.txt · everything: https://aiatlasgraph.com/llms-full.txt · updated 2026-10-31
