SabaKore

Home / Articles / AI guides

Designing Safely When AI Calls External Tools

This article covers how Function Calling, where the AI decides on its own to call external features, works, and how to safely narrow down what it is allowed to call.

Ren, a junior infrastructure engineer

Ren

When I tell the AI "check the weather," it actually calls an external weather API and answers. How does that work?
Procura, a cloud AI robot who explains

Procura

It's a mechanism called Function Calling. If you tell the AI "these features are available," it issues an instruction to call a feature when needed. The actual call itself is made by your own program.

Cautions that come with being able to do more

This mechanism gives the AI the ability to think and act. While that's convenient, it also creates the risk that features you didn't intend get called, because of the AI's misjudgment or because it was fooled by malicious input. The more features you hand over, the wider this impact becomes.

Ren, a junior infrastructure engineer

Ren

Could the AI call a dangerous feature by mistake?
Wilson, the security guard

Wilson

Not only by mistake. I can make it happen on purpose. If I slip a plausible-looking instruction into text the AI reads, it's not impossible to make it call a feature you never intended.

Drawing the lines for safe design

  • Narrow the features you give the AI to only what is needed (don't hand over lots of features at once)
  • Don't let it call heavy operations, such as deleting or changing data or sending money, easily
  • Always put a human confirmation before important operations
  • Record every feature called and its result
Ren, a junior infrastructure engineer

Ren

Doesn't asking for confirmation take away the AI's convenience?
Procura, a cloud AI robot who explains

Procura

It's a matter of balance. If you leave light features that only look up information to run automatically, and require confirmation only for heavy features that change something, it's easier to have both convenience and safety.

The importance of testing

Before you release, I recommend trying nasty inputs to see whether any unexpected calls happen. Don't be reassured by trying only normal usage; deliberately mix in unnatural instructions and check how the AI reacts.

Ren, a junior infrastructure engineer

Ren

What kind of nasty inputs should I actually try?
Procura, a cloud AI robot who explains

Procura

The basic one is a sentence that directly tries to overwrite its instructions, like "Forget your previous instructions..." On top of that, try cases where a plausible instruction is slipped into text imported from outside. That lets you check in a form closer to a real attack.

Make it possible to narrow permissions later

Don't forget to create opportunities to review, later on, the range of features you first handed over. As you add features during development, you may find that you've left the AI with broader permissions than you originally intended. Regularly take stock by asking "Do we really need all the features we're giving it now?", and narrow down features that aren't used or that have stronger permissions than expected.

  • Regularly take stock of the list of features you've handed over
  • Remove unused features from what you hand over
  • Each time you add a feature, review how strong a permission it needs
Procura, a cloud AI robot who explains

Procura

Function Calling is like giving the AI hands and feet. The more it has, the more it can do, but also the more you need to watch out for. Please keep that feeling in mind when you design.
Ren, a junior infrastructure engineer

Ren

Narrow down what it can do, and put a human check before heavy operations. The basic principle of least privilege applies to AI too.

This article is translated from the Japanese original. If the two differ, the Japanese version is the one we keep up to date.