Core Pillars

By the Syncfusion DevTutorials team · Last updated

The four parts every agent needs: reasoning, planning, memory and action. See what each one does, and watch an agent fail when one is removed.

Think about a skilled chef working in a busy kitchen.

The chef thinks about what the dish needs. The chef also has a plan: prepare the starter first, then the main course.

The chef remembers what is already being cooked. The chef also uses tools such as knives, pans, and ovens.

If any one of these is missing, problems can happen. A chef who forgets that food is in the oven may burn it. A chef with no plan might serve dessert before the main course.

An AI agent works in a similar way. It depends on four key pillars: reasoning, planning, memory, and action.

The main idea: An agent needs all four pillars to work effectively. If one pillar is missing, the agent can fail in a different way.

A Real-World Example

Think about the new team member from Lesson 1. They are fixing the row count bug on the ticket page.

  • Reasoning: "The test expected 80,000 rows but received 80,000 row. The issue is with the text, not the number."
  • Planning: "First, I will run the tests. Then I will read the file. Next, I will fix the issue. Finally, I will run the tests again."
  • Memory: "I have already read this file, so I do not need to read it again."
  • Action: They open the file, change one word, and run the tests.

People use all four of these abilities naturally without thinking about them. An AI agent must be designed to use each one intentionally.

In simple words: Reasoning decides, planning organizes, memory remembers, and action performs the work.

What You Will Learn

In this lesson, you will learn:

  1. How an agent uses reasoning to understand a situation and choose an action.
  2. How an agent uses planning to create a path toward a goal.
  3. How an agent uses memory to keep track of important information.
  4. How an agent chooses tools, uses them, and understands the results.
  5. What happens when one of the four pillars is missing.

This lesson uses the Agent Lab at the bottom of the page. You will run the same bug-fixing task multiple times. One version uses all four pillars, while the others remove one pillar at a time so you can see what happens when something is missing. All examples use the scripted brain, so the results are the same every time.

The four pillars of an agent. Reasoning decides what to do, planning organizes the steps, memory keeps track of information, and action performs tasks and returns results.

Start by running the complete agent. Read the reasoning shown at each step to see which part of the plan the agent is currently following.

An Agent with All Four Pillars

Reasoning

Reasoning is the process an agent uses to decide what to do next. It happens during the Think part of the agent loop.

Reasoning can be broken down into three smaller steps. These steps always happen in the same order.

Understanding the Current State

The state is all the information that is true at the current moment.

For example:

  • The tests have already been run.
  • Two tests are failing.
  • The file has not been read yet.

State evaluation means reviewing the current situation and asking questions such as:

  • Where am I now?
  • What information do I already have?
  • What still needs to be done?

Without this step, the agent cannot tell the difference between a completed task and a task that has not started.

Making a Decision

Decision making means identifying the most important thing to focus on next.

For example:

"Tests are failing, and I do not yet know why. Finding the cause is the highest priority."

The agent uses the information it has collected to decide what should happen next.

Choosing an Action

Action selection means choosing one specific action to perform.

For example:

"Read the file web/format.js."

An agent chooses one action at a time. After the action is completed, it reviews the result before selecting another action.

The next example shows all three parts working together in plain JavaScript. The code evaluates the current state, makes a decision, and then selects the next action.

Look at the state, then pick one action

function evaluate(state) {
  if (!state.testsRun) return "I don't know what is broken yet";
  if (state.failing === 0) return "Everything works";
  if (!state.fileRead) return "Something fails, and I don't know why";
  return "I know why it fails";
}

function selectAction(state) {
  const situation = evaluate(state);
  if (situation === "I don't know what is broken yet") return "run_tests";
  if (situation === "Everything works") return "finish";
  if (situation === "Something fails, and I don't know why") return "read_file";
  return "write_file";
}

const states = [
  { testsRun: false, failing: 0, fileRead: false },
  { testsRun: true, failing: 2, fileRead: false },
  { testsRun: true, failing: 2, fileRead: true },
  { testsRun: true, failing: 0, fileRead: true },
];

for (const state of states) {
  console.log(evaluate(state) + " -> " + selectAction(state));
}

Expected output:

I don't know what is broken yet -> run_tests
Something fails, and I don't know why -> read_file
I know why it fails -> write_file
Everything works -> finish

Each state leads to one specific action. In the JavaScript example, this is done using if statements. A real AI model performs the same task using natural language and reasoning instead of fixed rules.

The process is still the same:

  1. Evaluate the current state.
  2. Make a decision.
  3. Select the next action.

Now look at an agent that has no reasoning. This agent never checks the results of its actions. Instead, it repeatedly chooses the first tool available in its tool list.

Pillar Removed: Reasoning

The agent calls list_files six times and then reaches the step limit. It is performing actions, but it is not making progress toward the goal because it never evaluates the situation or decides what should happen next.

Planning

Planning is the process of deciding how work should be completed before starting. A plan breaks a large goal into smaller, manageable steps.

Defining the Goal

A goal definition clearly describes what success looks like. For example, "All tests pass" is a clear goal because the agent can verify whether it has been achieved.

The goal definition also acts as the agent's stopping condition. Without a clear goal, the agent does not know when its work is finished.

Sub-Goal Generation

A sub-goal is a smaller objective that helps achieve the main goal. For example, "Find the failing test" is a sub-goal that supports the larger goal of "Make all tests pass."

Breaking a task into smaller goals makes progress easier to track and verify.

Creating an Execution Plan

An execution plan is the list of sub-goals in the order they should happen. The order is important because some steps depend on earlier steps being completed first. For example, you must identify where a bug exists before you can fix it.

The next example takes a goal, breaks it into smaller sub-goals, and then identifies the next unfinished sub-goal.

A goal becomes an ordered plan

const goal = "Every test passes";

const plan = [
  { step: "Run the tests", done: true },
  { step: "Read the file the failure points to", done: true },
  { step: "Change the code", done: false },
  { step: "Run the tests again", done: false },
];

const next = plan.find((item) => !item.done);
const doneCount = plan.filter((item) => item.done).length;

console.log("Goal: " + goal);
console.log("Progress: " + doneCount + " of " + plan.length + " steps done");
console.log("Next: " + next.step);

Expected output:

Goal: Every test passes
Progress: 2 of 4 steps done
Next: Change the code

The plan helps answer two important questions at any time:

  • How much progress has been made?
  • What should happen next?

Now look at an agent that has no planning. That agent does not have a clear definition of what "done" means. It fixes the bug, but it does not know when to stop.

Pillar Removed: Planning

The tests pass at step 4. However, the agent keeps running the tests repeatedly until it reaches the step limit. Because it has no plan and no clear stopping point, it cannot recognize that the goal has already been achieved.

Easy Way to Remember: Reasoning asks "What should I do next?" Planning asks "In what order should I do it?" Memory asks "What have I already learned?" Action asks "Which tool should I use?"

Memory

Memory is the information an agent keeps from previous steps.

As you learned in the Context Engineering course, the model itself does not remember anything between separate calls. Because of this, the application must store important information and provide it to the model each time.

Working Memory

Working memory is the small set of information the agent needs for the current task.

For example:

  • The goal of the task
  • The latest test result
  • The contents of a file that was read

You can think of working memory as a notepad on a desk. It holds the information needed right now and is cleared when the task is finished.

State Tracking

State tracking means keeping memory updated after every step. For example, if the tests have passed, the stored state should say "tests pass" instead of the old state "2 tests failing".

Outdated information can be worse than having no information at all because the agent may make decisions based on information that is no longer correct.

Context Retention

Context retention means keeping important information available throughout the task. For example, if the agent discovers a test failure and later reads a file, it should still remember the test failure. Important information should not disappear just because new information was added.

The next example runs the same four-step task twice. The first agent remembers information from every step. The second agent only remembers information from the most recent step.

The same job, with and without memory

function nextStep(memory) {
  if (!memory.includes("tests failed")) return "tests failed";
  if (!memory.includes("file read")) return "file read";
  if (!memory.includes("code fixed")) return "code fixed";
  return "done";
}

function run(keepAll) {
  let memory = [];
  for (let step = 1; step <= 8; step++) {
    const result = nextStep(memory);
    if (result === "done") return "Finished in " + step + " steps";
    memory = keepAll ? [...memory, result] : [result];
  }
  return "Hit the step limit";
}

console.log("Remembers everything: " + run(true));
console.log("Remembers the last step only: " + run(false));

Expected output:

Remembers everything: Finished in 4 steps
Remembers the last step only: Hit the step limit

The agent without memory forgets that the tests failed as soon as it reads the file.

Because it cannot remember what it learned earlier, it keeps repeating the same actions instead of making progress.

See this behavior in the Agent Lab.

Pillar Removed: Memory

The agent runs the tests, reads the file, runs the tests again, reads the file again, and continues repeating the same cycle.

It never reaches the point where it fixes the bug because it keeps forgetting the information it just collected.

Action Systems

The action system is the part of the agent that interacts with the real world.

It has three main responsibilities.

Tool Selection

Tool selection means choosing the correct tool for the current task.

For example:

  • To find out which tests are failing, the agent should use run_tests.
  • To examine the code, the agent should use read_file.

The model chooses tools by reading their descriptions.

Because of this, clear and accurate tool descriptions help the agent make better decisions.

Tool Invocation

Tool invocation means calling a tool with the correct inputs. For example, the read_file tool requires a path value so it knows which file to open.

Before the tool runs, the application validates the inputs to make sure they are correct.

Environment Feedback

Environment feedback is the information returned after a tool finishes its work. For example: "3 passed, 0 failed".

This feedback tells the agent whether its action was successful and helps it decide what to do next.

Feedback is what completes the agent loop. Without feedback, the agent would be acting without knowing the results of its actions.

The next example chooses a tool by comparing the task requirements with the descriptions of available tools. It then runs the selected tool and uses the feedback to decide what to do next.

Pick a tool, call it, read the result

const tools = [
  { name: "run_tests", description: "run every test and show which fail", run: () => "1 passed, 2 failed" },
  { name: "read_file", description: "read the text of one file", run: (path) => "text of " + path },
  { name: "write_file", description: "change the text of one file", run: (path) => "saved " + path },
];

function selectTool(need) {
  const words = need.toLowerCase().split(" ");
  return tools.find((tool) => words.some((word) => tool.description.split(" ").includes(word)));
}

const needs = [
  { need: "which tests fail", input: "" },
  { need: "read the format file", input: "web/format.js" },
];

for (const item of needs) {
  const tool = selectTool(item.need);
  const feedback = tool.run(item.input);
  console.log(item.need + " -> " + tool.name + " -> " + feedback);
}

Expected output:

which tests fail -> run_tests -> 1 passed, 2 failed
read the format file -> read_file -> text of web/format.js

This keyword matching example is much simpler than how an AI model selects tools. However, the core idea is the same: the tool's description helps determine when that tool should be chosen.

Now look at an agent that ignores feedback. Instead of checking whether its change worked, it writes a guessed fix and immediately claims the problem is solved.

Pillar Removed: Action Feedback

The agent reports "Fixed." after only 2 steps.

Now open the Files tab and click Run tests. The tests still fail. The agent sounded confident, but it was wrong because it never verified the result of its action.

An agent saying "done" does not prove the task is complete. Only feedback can confirm that. Always make the final step a verification step, such as running tests and checking the results.

All Four Pillars Together

The following example shows an agent loop that uses all four pillars together. Each pillar handles a small but important part of the process.

One loop, four pillars

const plan = ["run_tests", "read_file", "write_file", "run_tests"];
const memory = [];
const world = { failing: 2 };

const tools = {
  run_tests: () => world.failing + " failing",
  read_file: () => "found the wrong word",
  write_file: () => { world.failing = 0; return "saved"; },
};

for (let step = 1; step <= 6; step++) {
  const goalDone = memory.length > 0 && memory[memory.length - 1] === "0 failing";
  if (goalDone) { console.log("Step " + step + ": finish"); break; }
  const action = plan[memory.length];
  const feedback = tools[action]();
  memory.push(feedback);
  console.log("Step " + step + ": " + action + " -> " + feedback);
}

Expected output:

Step 1: run_tests -> 2 failing
Step 2: read_file -> found the wrong word
Step 3: write_file -> saved
Step 4: run_tests -> 0 failing
Step 5: finish

Find each pillar in the code:

  • Planning: The plan list defines the order of work, and the goal check "0 failing" determines when the task is complete.
  • Memory: The memory list stores feedback from each step. A new result is added after every action.
  • Reasoning: The goalDone check determines whether the agent should stop, and the next action is chosen based on the information stored in memory.
  • Action: The tools object contains the available actions. The call tools[action]() executes the selected action and returns feedback.

Common Mistakes

MistakeWhat HappensMissing PillarHow to Fix It
The agent repeats the same tool over and overThe same action runs repeatedly until the step limit is reachedReasoningMake sure the agent checks the latest result before choosing the next action
The agent never stopsThe task is complete, but the agent continues runningPlanningClearly define what "done" means and check it after every step
The agent keeps switching between two actionsIt reads a file, runs tests, reads the file again, and repeats the cycleMemoryStore important results from previous steps instead of keeping only the latest one
The agent says "Fixed" when the problem still existsThe task ends quickly without verifying the resultAction feedbackAlways perform a final verification step and check the returned feedback
The agent chooses the wrong toolIt reads files when it should be running testsAction (Tool Selection)Write clearer and more specific descriptions for each tool

Exercises

Each exercise ends with a value on the last line. Press Check to compare it with the expected answer.

What to Remember

  • Every agent is built on four pillars: reasoning, planning, memory, and action.
  • Reasoning evaluates the current state and decides what action to take next.
  • Planning defines what success looks like and organizes the steps needed to reach the goal.
  • Memory stores important information from previous steps and must always stay up to date.
  • Action selects a tool, uses it, and reads the feedback returned by that tool.
  • Feedback is the only reliable way to confirm whether an action worked and whether the goal has been achieved.

Next: System Architecture, the parts inside an agent program and how they fit together.