Skip to content
AgentLabs.

AI Agent Observability and Logs: What to Keep and What to Exclude

AI Agent Observability and Logs: What to Keep and What to Exclude

Observability for the AI era: when an AI agent becomes a dangerous black box

If you work with an AI agent today, whether at a young Herzliya start-up, in the data team of a huge financial company or even on a quick proof of concept you made for yourself, there is a confusing moment that keeps recurring. The system does something unexpected, and you ask, “Wait, how did that happen?”

In ordinary software systems, most of us have learned to live with logs, metrics and traces. Somehow, everything seems more or less understandable: code, requests, responses. But when the AI agent decides, plans, speaks to users, writes code and opens tickets, observability suddenly feels like something that needs reinventing too. Above all, a question walks through the door with a lawyer behind it: what may we retain, and what must never appear in logs?

On one hand, without detailed logs, there is no learning, improvement or way to understand why an AI agent acted in a particular way. On the other, if we record everything, we quickly acquire logs containing sensitive, private and business information, sometimes legally dangerous information too. This is not hypothetical; it is happening now as you read.

Why does an AI agent need observability at all?

To understand what to retain and what not to, we first need to remember why we bother recording every little thing the agent does. This is not another microservice or API. An AI agent system behaves, to a considerable extent, like a talented but somewhat impulsive new employee. It receives general instructions, interprets them and tries to manage. If we cannot see what is happening in its head, we wake up one day to find it answering customers about prices that have not yet been published.

Observability for AI agents includes several layers:

The behavioural layer: what the agent actually did

This is the most intuitive layer: which actions were performed, against which systems, in what sequence and with what outcome. When an AI agent acts as business automation, for example opening tickets, generating emails or updating CRM, we want to understand its chain of actions, beyond the final result.

The thinking layer: why it did it

Advanced AI agents, particularly those using multistage planning, chain of thought and similar approaches, create a hidden layer: internal logic and the thinking process. Some systems diligently retain it, or at least offer that option. It is tempting, like seeing the system's personal diaries for the first time. But this is precisely where the problem begins: much of this thinking may include sensitive, private information that you would not want retained in a data lake forever.

The contextual layer: who the user is, where they are and what matters here

A good AI agent does not operate in a vacuum. It uses context: user details, permissions, interaction history and organisational documents. When that context flows into prompts and responses, it can leak into logs too. This takes us beyond observability to privacy, regulation and sometimes even national-level information security, including in Israel.

Proper AI agent logs: between “I need to know everything” and “better not to know”

One of the most common statements I hear from developers starting with AI agent observability is, “Come on, let's save everything; we'll work out what to do with it later.” It sounds reasonable, but with sensitive information, this is more than a mistake; it is a direct risk.

What is almost always important to retain

Without treating lists as sacred, there are several information types almost always worth documenting, even when we are very careful to avoid personal or confidential data:

1. Request metadata, rather than raw content

Instead of retaining everything the user wrote to the AI agent, you can retain:

  • The request time.
  • The action type, such as “Create an email draft”, “Update a task” or “Search query”.
  • Message length: token or word counts, rather than the words themselves.
  • Status: success, failure, warning or exception.
  • Execution time, number of model calls and resource usage.

All this provides enough material to understand where the system gets stuck, without holding full texts that may contain secrets.

2. The AI agent's key decisions

In systems where an AI agent plans steps, such as reading an email, analysing intent, opening a task and sending a response, retain a log at the level of what the flow was, rather than necessarily its exact wording. For example:

  • Intent identification: “Technical support request”, “Sales question” or “Urgent fault”.
  • Tool selection: “Chose to search documents” or “Chose to email a manager”.
  • Action status: completed, failed or cancelled by the user.

This also helps manage risk: if an AI agent suddenly starts always choosing the wrong tool, you will see it in the logs.

3. Errors and blocks from model providers

Models such as GPT, Claude and others return plenty of errors, warnings and sometimes blocks from safety filters. These must be documented, including:

  • The error code.
  • The block type: sensitive content, violence or usage policy.
  • A retry attempt and its outcome.

Even here, however, retaining the entire blocked prompt is not necessary, and is not always permitted. Retain the technical context instead.

What must not be retained, even if it would really help debugging

This is where we enter a minefield. When an AI agent speaks to users, especially in healthcare, finance, law or even HR, the texts sent to it can contain anything: names, identity numbers, medical descriptions, business secrets and even passwords. Yes, users still do that.

1. Direct personal identifiers

If your logs contain:

  • Identity numbers.
  • Credit card numbers.
  • Bank account numbers.
  • Full home addresses.
  • Personal email addresses combined with a full name.

You are violating almost every reasonable privacy standard and creating a time bomb for yourself. A leak would be more than an embarrassment; it would be a significant security incident.

2. Identifiable medical or legal data

An AI agent used as a medical assistant or virtual lawyer, or simply a chatbot on a health fund's website, may receive highly specific descriptions: illnesses, treatments, legal cases, parties' names and legal documents. Retaining this unchanged in logs? A bad idea.

Instead, retain parts detached from identity, or a general tag such as “This conversation was medical in nature” or “The user was interested in disability rights”, without the full description.

3. Full chain of thought involving sensitive content

One of the greatest temptations when working with a planning AI agent is retaining its entire thinking process: every draft and all internal reasoning. This is gold for developers, but also a privacy minefield. Models tend to weave user content, internal documents and identifying passages into it. Everything then gets thrown into logs and lives there forever.

More and more organisations in Israel and worldwide are adopting a rule of not retaining raw chain of thought in production systems, or at least applying aggressive anonymisation before it is written to a log.

Where is the line? Product needs versus privacy and trust

There is a basic tension particularly visible in AI agent observability: product wants as much information as possible, while legal and security want as little as possible. Developers and DevOps staff sit in the middle, trying to find a balance that does not paralyse everyone.

From a product perspective: no data, no improvement

Improving AI agents, understanding where they make mistakes, become confused or excel, requires raw material. Otherwise, every piece of feedback becomes anecdotal: “I heard from a user that the answer wasn't accurate.” From a product perspective, retaining full conversations looks like a dream: you can analyse errors, improve prompts, train additional models and even show customers before-and-after comparisons.

From a privacy perspective: the user did not volunteer to become a dataset

Conversely, ask average users whether they are comfortable with everything they wrote to an AI agent being retained forever, made accessible to dozens of employees and perhaps used to train future models. Most, to put it gently, will be unenthusiastic. That is before considering GDPR, Israeli privacy legislation and internal guidelines in sensitive organisations.

Healthy practice: logs capturing substance, rather than raw text

One interesting approach emerging today, including at Israeli companies, is retaining substantive logs: the characteristics of the words, rather than the words themselves. Instead of:

"The user wrote: I need urgent help; my mother has been hospitalised..."

We retain:

"Title: An urgent request for help in a medical context involving a first-degree family member"

This requires another processing layer, another AI agent stripping away sensitive information. But the result, useful observability without holding all the users' distress in plain text, is worth it.

Israel, 2026: AI agents enter organisations while logs run ahead of policy

The pace at which Israeli organisations adopt AI agents surprises even longstanding sceptics. From law firms trying to turn human secretarial work into an intelligent legal assistant to bank customer service departments introducing an AI agent as the first response line. While this happens, logging policy is usually built too late, sometimes simply copied from classic systems without recognising that the game is different.

Israel's “we'll check the logs” culture

Let us admit it: Israel has a fairly strong culture of “throw it in the log and see”. Developers like having as much information as possible afterwards, particularly when a product manager stands over them asking, “Why did this happen?” But AI agent logs are more than another microservice stack trace. They can provide a deep glimpse into a user's personal life.

This means the organisation must act before trouble arises: build a logging policy specifically for AI agents, state explicitly what must never be retained and define who may see what is retained.

A small example from the field

One large Israeli organisation, which will remain unnamed, introduced an internal AI agent intended to help employees find information in company documents. Initially, every query was logged in full “to improve search”. It soon emerged that employees were also searching for salary documents, retirement agreements and internal legal disputes. All this reached log management unchanged, with fairly broad access for development teams.

After an unpleasant internal incident involving an angry email from HR, the organisation moved to another model: logs retained only intent types, document categories and response times, rather than the full query text. The truth? Observability actually improved: less noise, more signal.

What should you retain? Some imperfect guidelines

There is no single correct answer, so principles are preferable to a rigid list. Particularly when one AI agent in an organisation is a service-centre chatbot, while another is an automation agent working on server logs.

Principle 1: do not retain raw user text by default

Unless there is a very good reason, legal, commercial, agreed and defined, it is better to start from not retaining the user's words as they are. If you must retain them:

  • Break them into anonymous parts.
  • Apply personally identifiable information masking.
  • Significantly restrict retention time: days, rather than years.

Principle 2: retain decisions, rather than thoughts

For most use cases, the interesting part of AI agent logs is the decision points, rather than all the excess thinking: whether an action was approved, which tool was selected and what the user's intent was judged to be. You can document each stage's conclusion without carrying all its drafts along.

Principle 3: separate observability from data labelling

Many organisations try to use logs to label data for future model training too. This saves time, but also confuses the objectives: logs are intended for understanding and ongoing operation, rather than training models. If conversations are to be used for training, put them through a separate approved process with anonymisation and appropriate consent.

Principle 4: transparency with users

If an AI agent speaks to end customers, trust and regulation alike require a reasonable explanation of what is retained, for how long and why. You do not need a legal novel, but something such as “The conversation may be retained anonymously to improve the system”. If it is not anonymous, say so honestly.

Questions and answers about AI agent logs

May all AI agent conversations be retained to improve the product?

Technically, yes. Morally, regulatorily and commercially, it is a very risky decision. In most cases, retain only anonymous portions, or filter and mask before writing to a log. If you choose to retain full conversations, you need a clear policy, informed user consent and very serious technical and legal safeguards.

How can you debug an AI agent without seeing everything the user wrote?

Use summarised logs: intent, category tags, action statuses, error codes and a general request description without identifying details. In staging environments with synthetic data, you can work with full text, but do not transfer the same practice to production.

Should the model's chain of thought be retained for analysis?

Only if you know exactly what you are doing and are certain there is no sensitive information there, which is almost never the case in production. You can retain a concise or bullet-point version of reasoning, meaning key decisions, without the raw text the model generated for itself while thinking.

Who in the organisation needs access to AI agent logs?

Fewer people than you think. Applying least privilege is strongly recommended: developers receive error and process data without user details; information security teams receive access to anomalous activity; and product receives statistics and analyses, rather than users' raw texts.

Can the same logging rules be used for every kind of AI agent?

No. An AI agent helping write internal code is completely different from a medical customer service chatbot. Each kind needs a tailored policy: what it sees, what it returns, how sensitive that is, whom it serves and the risk level if a leak occurs.

Table: key points on what to retain and exclude from AI agent logs

Information typeRetain it?Points to consider
Metadata: time, status, duration, message lengthUsually, yesUseful for observability, generally without exposing sensitive information
Full user request textOnly for a special needData masking, limited retention and restricted access are recommended
AI agent decisions: intent, tool selection, action statusYesThe heart of behavioural observability, without needing all raw text
Raw chain of thoughtIn most cases, not in productionMay contain sensitive information; retain only a decision summary instead
Personal identifiers: identity number, credit card, bank accountNoApply masking or anonymisation before writing to a log
Identifiable medical or legal dataNoIf necessary, retain only general tags, rather than full text
Error codes and model provider warningsYesCritical for debugging and quality monitoring; does not require full user text
Usage statistics: user numbers and features usedYesA foundation for analytics; maintain anonymity at user level
Full conversations for model trainingOnly through a protected processSeparate from operational logs, with controls, anonymisation and consent

An opportunity as well as a headache: observability in an AI agent's DNA

Ultimately, proper AI agent logs are more than legal protection or a debugging tool for desperate developers. They are an opportunity to build trustworthy AI systems: systems that neither hide everything inside a black box nor pour all sensitive content into files whose access nobody really understands.

AI agent observability can be viewed as a new contract between user, organisation and technology: the user is willing to share, the organisation commits to protect and technology, if designed properly, lets us see what is needed for improvement without seeing too much.

It will not be perfect. There will be dilemmas, mistakes and painful retrospectives. But the earlier logs are considered during AI agent specification, rather than left until the end as “we'll add a few print statements to the log”, the greater the chances of a system enduring technically, morally and regulatorily.

Finally: if you are building an AI agent, do not wait for logs to become a problem

If there is one lesson, it is fairly simple: AI agent observability needs planning like any other critical feature, with difficult questions from the outset. What will we record? Who will see it? For how long? What happens if there is a leak? How do we retain professional and product value without giving up privacy, trust and, to put it simply, peace of mind?

If your organisation is starting to work with AI agents but policy around logs, privacy and observability still feels behind, this is precisely the time to pause, clarify and ask questions. We would be happy to help with an initial consultation at no cost, building a balanced approach that makes your AI agent intelligent, useful and, above all, something you can stand behind the next day too.

From reading to a pilot

Define how you will know the pilot succeeded

Choose a business measure, a quality measure and edge cases. We will assess how to compare them with your current process.