Skip to content

Code Task Agent

Code Task Agent is an AI agent that solves tasks by writing short programs and running them in an isolated environment. You ask for something like “read this Excel file, work out sales by region and make a chart”, and the agent writes the code, runs it, checks the result and fixes it until the task is done.

The files it produces, such as charts, spreadsheets or documents, are saved to the conversation and appear in the answer: images are shown directly and everything else as download links.

When to use it

  • You want the sales team to ask about their sales data in the chat and get figures and charts.
  • You need to clean, merge or transform Excel or CSV files without doing it by hand.
  • You want to pull information out of PDF documents and summarise it in a table.
  • You need calculations an AI model does not do well on its own, such as totals over thousands of rows.

Configuration

FieldWhat it does
Agent NameThe agent’s name. It is used when you connect it as a tool or as an agent of another agent. Default: Agent.
Agent DescriptionWhat the agent does, in one sentence. It helps other agents decide when to use it.
User PromptThe text the agent receives. Default: {input}, which is replaced by whatever arrives at Input. You can add other variables in curly braces; each one appears as a new field.
InputThe user’s request, usually connected from a Chat Input.
System PromptThe agent’s general instructions: its role, tone and the rules it must follow. Default: You are a helpful AI assistant.
ConnectionWhat to connect
Model (required)The AI model that drives the agent, for example OpenAI or Anthropic.
ToolsOptional. Other tools the agent can use besides running code.
Input FilesOptional. The files the agent must work with. Files uploaded in the chat conversation are also available without connecting them here.

Advanced options

FieldWhat it does
Max IterationsThe maximum number of times the agent can run code for each task. Default: 35.
Recursion LimitThe maximum number of internal steps the agent can take for each answer. It should be much higher than Max Iterations. Default: 1000.
Use memoryMakes the agent remember the previous messages of the conversation. When you turn it on, the Memory connection appears, where you can connect a memory component such as Postgres Memory. Default: off.
StreamShows the answer in the chat as it is generated. When you turn it on, Stream Thinking appears, which also shows the agent’s reasoning. Default: off.
Include State in responseAdds the agent’s internal working data to the answer, for use in later components. Default: off.
Enable PythonLets the agent write and run code in this language. Default: on.
Enable Node.jsLets the agent write and run code in this language. Default: on.
Execution Timeout (s)The maximum time, in seconds, of each code run. Default: 120.
Python VersionThe language version the code runs with. Default: 3.13.
Node.js VersionThe language version the code runs with. Default: 22.
Memory LimitThe maximum memory the environment that runs the code can use, for example 512m or 1g. Default: 1g.
Default PackagesThe add-ons installed in the environment in advance for the code to use, one per line. The initial list already covers spreadsheets, charts, images, web pages and PDF. For Node.js ones, write npm: in front of the name.
Extra InstructionsInstructions added to the agent’s own, for example the format you want the results in.

Batch processing

With the Batch Mode switch on, the component runs once for each item of the list you connect to Batch Input and returns all the results together as a list. Parallel Executions sets how many items are processed at the same time (1 to 5). Skip if Empty Batch Input skips the component when the list arrives empty, and Skip Branch if Empty Output stops the following components when the result is empty. More in Key concepts.

Using it as an agent tool

You can connect this component to an agent’s Tools input. In the Tool tab, Tool Name and Tool Description are the name and explanation the agent uses to recognise the tool and decide when to call it: write a clear description of what it does.

Output

  • Response: the agent’s answer as a chat message, with the generated files at the end. Connect it to a Chat Output.
  • Agent: the whole agent, to connect it to another component that coordinates agents, such as Planner Executor Agent or Supervisor Agent.
  • Tool: the agent as a tool, to connect it to another agent’s Tools input.

Example

The finance department of a retail chain wants to analyse its sales from the chat.

  1. Connect a Chat Input to Input and an AI model to Model.
  2. In System Prompt write: You are a financial analyst. Answer with clear figures and, when it helps, with a chart.
  3. Connect Response to a Chat Output.
  4. In the chat, upload the quarter’s sales Excel file and ask: Which store grew the most compared with the previous quarter? Make me a bar chart.

The agent reads the file, does the calculations and answers with the explanation and the chart.

Good practices

  • Say in the request what result you expect and in which format (a table, a chart, an Excel file).
  • If heavy tasks get cut off, raise Execution Timeout (s).
  • Check important figures before using them in a decision.
  • Coding Agent V2: a conversational assistant to write and review code.
  • Agent: NappAI’s general agent.