setFunctions

View as MarkdownOpen in Claude

Set which non-internal functions are callable while this step is active. Restricting functions per step prevents the AI from calling irrelevant tools and keeps the per-step active set small — LLM tool selection accuracy degrades noticeably past ~7–8 simultaneously-active tools per call.

Step toolsets inherit from the previous step. If you do not call setFunctions() on a step, it inherits whichever function set was active on the previous step (or the previous context’s last step). The server-side runtime only resets the active set when a step explicitly declares its functions field. This is the most common source of bugs in multi-step agents — forgetting setFunctions() on a later step lets the previous step’s tools leak through. Best practice: call setFunctions() explicitly on every step that should have a different toolset than the previous one.

Internal functions (startup_hook, hangup_hook, gather_submit, etc.) are always protected and cannot be deactivated by this whitelist. The native navigation tools next_step and change_context are injected automatically when setValidSteps() / setValidContexts() is set; they are not affected by this list and do not need to appear in it.

Parameters

functions
string | string[]Required

One of:

  • string[] — whitelist of function names allowed in this step. Functions not in the list become inactive.
  • [] — explicit disable-all (no user functions callable).
  • "none" — synonym for [], same effect.

Returns

Step — Self for method chaining.

Example

1import { ContextBuilder } from '@signalwire/sdk';
2
3const builder = new ContextBuilder();
4const ctx = builder.addContext('default');
5const greet = ctx.addStep('greet');
6greet.setText('Welcome the caller.');
7greet.setFunctions('none');
8const verify = ctx.addStep('verify');
9verify.setText('Verify the caller\'s identity.');
10verify.setFunctions(['lookup_account', 'verify_identity']);