A validated export config object.
Values for what the export redacted or replaced.
A new Agent instance constructed from the config.
If the config is invalid, if the roster holds a pre-built seat, or if a redacted value or instance marker has no entry; the error lists every such path.
const config = JSON.parse(fs.readFileSync('agent.json', 'utf-8'));
const agent = importAgent(config, {
secrets: { '/agents/support/channels/slack/credential': process.env.SLACK_BOT_TOKEN! },
values: { '/config/router': myRouter },
});
const reply = await agent.generate('Hello!');
Imports an agent from an AgentExportConfig object.
For
type: 'agent', calls theagent()factory with the stored config. Fortype: 'agency', calls theagency()factory with the stored config plus the sub-agent roster and strategy. The roster is read fromagents; the copy insideconfigis dropped.Exports redact secrets and replace class instances by default, so import restores them:
options.secretsmaps the JSON Pointer of each redacted string to its value, andoptions.valuesmaps the pointer of each<<instance>>marker (or dropped function) to the object to put there; only a non-empty string restores a secret, and an undefined or null value puts nothing back. A redacted provider key beside a model provider agentos knows, with no entry, resolves as an unset key does (an applicablesetDefaultProvider()default, then the environment). A redactedbaseUrlbeside one, with no entry, is dropped when a default naming that provider carries abaseUrlor the provider's URL variable is set, each read as the agent's calls read it: an empty or whitespace-only one is unset, so a default withbaseUrl: ''leaves the variable to apply, and neither lists the path. A roster seat's own key or URL, and a key beside any other provider, is listed.The document is copied in the serialized form (functions left out, class instances as markers), so importing the object form of an unredacted export lists its instances and drops its functions: pass them through
values.