Forge Development

Hallucinations in Custom Rovo Agents, Part 2: How to Contain Them

Matthias Rauer •
#Forge#Rovo#AI#LLM#Development
An AI agent's documents, searches, and blocked requests pass through a security check before reaching a verified result

Part 1 of this series showed how to make hallucinations visible and measurable with structured logs, a test set, and six metrics. Part 2 describes the measures you can take to improve those numbers, and names the metric for each one that shows whether it worked.

The underlying principle: the language model never executes anything itself. It decides which action to call with which inputs, and then reports what happened. So the model should have to decide as little as possible, and the code should check everything the model passes to it.

Precise action descriptions

Target metrics: action accuracy, input fidelity

The agent only knows actions through their descriptions and uses them to decide when to call them. A vague description forces it to guess, and every guess carries the risk of a wrong choice. A good description answers three questions, here using the retro agent from Part 1 as an example:

VaguePrecise
What”Retrieves retro data.""Reads the action items of a retrospective from the corresponding Confluence page.”
When–“Use when the user asks about the results or decisions of a specific retro.”
When not–“Not for general questions about how the sprint went; use the ‘Get sprint report’ action for that.”

The same applies to inputs: “Sprint” leaves open whether a name, number, or ID is meant. “Sprint number as used in the retro page title, e.g. 42” is much clearer. It also helps to note when the agent should ask a follow-up question instead of guessing a value, for example when the user doesn’t name a sprint.

Few, focused actions

Target metric: action accuracy

The more actions an agent has, and the more similar they are, the more easily it confuses them. For the Rovo agent builder, Atlassian recommends fewer than five actions per agent. There is no fixed limit for Forge agents, but the rule of thumb carries over: give an agent only the actions it needs for its task, and clearly separate their responsibilities. As the scope grows, several specialized agents are usually the better choice.

Then there’s the prompt, which has to explain every action and quickly becomes unwieldy as their number grows. This is where the rovo:skill module, currently in preview, helps: it moves task-specific procedures out of the prompt, such as how to coordinate several actions or how to handle errors. The agent prompt can then be limited to role and boundaries.

A prompt that demands evidence

Target metrics: grounding rate, refusal rate

Content hallucinations can’t be prevented by validation alone; the prompt is the most important lever here. Three rules have proven effective:

  • Answer only from evidence: Factual claims are based exclusively on action results and content that was actually retrieved. The agent separates documented facts from its own conclusions. If the retro page says “Evaluate caching,” that is not a decision to introduce caching.
  • Cite sources: An issue key or page URL for every statement. This is the prerequisite for the grounding check from Part 1.
  • Allow “not found”: Models would rather deliver an answer than admit a gap. The prompt should make clear that “I couldn’t find any information on that” is a welcome answer.

The code still helps: it can check whether cited sources exist, and it can return structured facts instead of free text, which leaves less room for misinterpretation.

It also helps to tell the agent which data it can reach. Agents from Forge apps only see the data of the Atlassian app they are installed in: an agent installed in Jira doesn’t automatically see Confluence pages, not even on the same site, unless the app is configured for multiple Atlassian apps, which is currently in preview. If a user asks about such data anyway, the temptation to make something up is high.

Validate inputs, prefer context

Target metric: input fidelity

Atlassian itself warns that the model extracts inputs from the conversation and context, which leaves them subject to hallucination. The action therefore must not trust any input, and instead checks every value against the actual data: Does the issue exist? Is the value within the valid range?

The context that Forge provides is more reliable. If the user is currently viewing a Jira issue or a Confluence page, the payload contains identifiers such as the issue key or content ID, and these are passed deterministically. If the request refers to the object the user is currently looking at, the action should prefer the value from the payload over an input. Blindly preferring it is wrong, though: a user viewing PROJ-456 may well ask about PROJ-123. If the input and the context differ, the action should treat the request as ambiguous rather than silently pick one. For permissions, the user’s identity (the accountId) comes from the invocation context, never from an input. Whether the user is allowed to perform the specific operation is something the action still has to check afterwards.

The error message for rejected inputs matters, too. “Invalid input” may tempt the agent into a second attempt with another invented value. “Sprint 99 does not exist; existing sprints in the project: 40 to 45” gives it everything it needs for a correct answer, provided the user is allowed to see those sprints. And the action should only report “does not exist” if it has actually established that. If the user lacks permission or the API fails, that calls for a different status.

Unambiguous return values

Target metric: execution fidelity

The agent translates an action’s result into natural language, and this is exactly where claimed and concealed executions arise. The less room for interpretation the result leaves, the less often this happens. A uniform structure across all actions has proven effective:

FieldContentExample
StatusSuccess or error typeSuccess
Short messageSuggested wording for the answer to the user”3 issues created”
Affected objectsIdentifiers for citing sourcesRETRO-101, RETRO-102, RETRO-103
Error reasonFor errors, the cause in plain language–

The structured fields are what counts. Even the best return value doesn’t guarantee that the agent reproduces them correctly. The prompt can additionally specify that the agent passes on status and message without reinterpreting them. If a false success message would be critical, that exact case belongs in the test set from Part 1.

Safeguarding write actions

Goal: damage limitation

Here, the point is less about a rate and more about limiting the damage if something goes wrong despite everything. Three layers of protection work together.

Confirmation by the user. Every action carries an actionVerb: GET, CREATE, UPDATE, DELETE, or TRIGGER. In practice, Rovo asks for confirmation before running actions that are not declared as GET, while GET actions run without it, as observed in the developer community. However, the Forge documentation doesn’t guarantee this for every invocation context. Declare reading actions as GET and writing actions never as GET, but don’t rely on this alone for critical changes. Good to know: Forge agents triggered by automation rules only invoke GET actions.

Preconditions in code. Confirmation only protects you if the user actually reviews the proposal. If a sprint may only be closed when it has no open issues, the action checks this itself, immediately before the change, because the data may have changed since the proposal was made.

Minimal permissions. The app requests only the scopes its actions need. If the agent does choose the wrong action, the damage is limited to what the app is allowed to do at all, which can still be considerable. Scopes, user permissions, and business preconditions are therefore separate layers of protection; none of them replaces the others.

Your own LLM logic with the Forge LLMs API

Target metric: consistency

With the Forge LLMs API, you have more levers than in the agent module, where you can only shape the behavior through prompt, actions, and skills, and can’t choose the model. The model call accepts a temperature parameter, for example. According to the API reference, you can set either temperature or top_p, but not both. A lower temperature can reduce the variability of answers, but it doesn’t make them more correct. Also, not all models in the Forge LLMs API support these parameters, so check this for the model you choose.

More important is control over the tool loop: the code checks every tool result before it goes back into the model, limits the number of iterations, and only allows the model the tools and parameters intended for the task. Wherever it processes a model response further, it specifies a fixed format and validates it instead of interpreting free text. Valid JSON is not yet a correct result in business terms, though.

Proving the effect

Each of these measures remains a hypothesis until the test set from Part 1 confirms it. The rule is: one change, one regression run, and across the entire test set, not just the affected cases. An improvement in one place can cause new errors elsewhere. If you revise descriptions, prompt, and validation all at once, you won’t know afterwards what made the difference.

Conclusion

Hallucinations can be contained through architecture, and the most effective measures aren’t the most spectacular ones: clear descriptions, few actions, a prompt that demands evidence and allows gaps, and code that accepts nothing unchecked. Together with Part 1, this results in three building blocks: verifiability, measurement, and containment.

One further class of risk is deliberately left out: content in Jira or Confluence that contains embedded instructions and thereby influences the agent. That has nothing to do with hallucinations, though. It’s a security problem in its own right, and one that deserves its own article at some point.

← Back to Blog