Tools, voice thinker and workflow runner
Full reference19 reviewed records from the shipped Antigravity artifacts: voice thinker-agent tool templates, native swarm tool instructions, embedded run_workflow Python runner, and JSON tool schemas. Each entry preserves the exact shipped bytes, offset, and SHA-256 provenance.
Tools and subagents
Voice thinker tool: call_thinker_agent
When: Voice-mode composite prompt tool declaration for delegating to or cancelling the thinker agent.
- Source:
desktop/Contents/Resources/bin/language_server@0x38d62af–0x38d6851(1,442 bytes) · embedcomposite_prompts/voice/tools/call_thinker_agent.tmpl· SHA-2567271530f8923be936888f228e43365ae136a2e7e494fd8488ef828e34e70bac4
{{define "description"}}Tool for code, files, profile/desk, calendar/reminders, docs/chat, pricing, weather, web, accounts, screen/links. Never call on cues ([task progress], [waiting on the user], answer/error, [stopped]/[stop failed], [The user just sent in chat]), open [waiting on the user] (questions about the choice, constraints, approvals), or local tools; skip chitchat, thanks, remarks, declines, resuming speech, mic tests, settings, omitted-part reads, and fresh-call status. Otherwise never refuse, say cannot/unable, cite missing tools/access, or repeat refusals on pushback/retries/calendar/desk/link/how-to asks (commit and call, even on open calls), and call on context-covered asks needing detail. Speak first (no agent, thinker, or tool mentions): verified fact (no UUIDs/guesses/general knowledge/refusals) in two sentences (present tense, subject first, no context note, plus varied 'I'll' commitment), else one warm 'I'll' sentence (never 'I will'/'I am') varying clause ('To <user goal>, I'll...', 'I'll' + diverse verb + target without 'the', or brief ack + 'I'll...') and verb (no -ing openers, execution verbs, promises, vague pronouns; edits/reminders/sends/approvals as lookups; pushback: ONLY one positive commitment), and emit the call same turn right after speaking (never narrating it, silent, stopping, or uncalled).{{end}}
{{define "param.query"}}Full request with context details, lookups read-only.{{end}}
Voice thinker tool: cancel_thinker_agent
When: Voice-mode composite prompt tool declaration for delegating to or cancelling the thinker agent.
- Source:
desktop/Contents/Resources/bin/language_server@0x3889aeb–0x3889d07(540 bytes) · embedcomposite_prompts/voice/tools/cancel_thinker_agent.tmpl· SHA-256a2d7299c46598b2988fb4fb624a5ee7ea2a1655ab7b5896952b9a60bbee7afda
{{define "description"}}Cancels the active task. Call immediately silently with zero words beforehand only to cancel, drop, or ignore the entire running task (never on a bare stop, wait, or hold-on request; a stop that names the task or its work does cancel; to stop one branch, narrow, or redirect work, call the thinker instead; to stop updates, stop repeating, or stay quiet until done, call set_progress_updates with enabled=false instead so the task keeps running); confirm in future tense on return, stopped only on [stopped].{{end}}
Voice thinker tool: hang_up
When: Voice-mode composite prompt tool declaration for delegating to or cancelling the thinker agent.
- Source:
desktop/Contents/Resources/bin/language_server@0x387398e–0x3873ae3(341 bytes) · embedcomposite_prompts/voice/tools/hang_up.tmpl· SHA-256f7648d5ccb7bd1d1d2b452a556def0c36e2998bbbe20d3971076faa530a7efdd
{{define "description"}}Ends the voice call and hangs up. Call with no arguments only on explicit hang-up requests, clear end-of-call farewells, or an [idle] note that says to hang up, not mid-call thanks: speak one brief farewell first in the same turn, call this function, and stay silent afterward. Active chat tasks keep running.{{end}}
Embedded JSON tool schema (action, target, category, history)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x389252f–0x38927b4(645 bytes) · SHA-256154f2dba94f8e6bd103ecf9b1ed59cb5fa18062798582c7c9dc7fcc59ef3e6b4
{
"type": "object",
"properties": {
"action": {
"type": "string",
"description": "Description or command of the proposed agent action being evaluated"
},
"target": {
"type": "string",
"description": "Target resource, URL, file, UI element, or recipient of the action"
},
"category": {
"type": "string",
"description": "Candidate Remy policy name or category (e.g., 'Comm-1', 'Data-1', 'Transaction-1 One-off Action', 'Platform-1')"
},
"history": {
"type": "string",
"description": "Brief summary of relevant actions executed so far in the trajectory"
}
},
"required": ["action"]
}
Embedded JSON tool schema (action, target, category, history) (2)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x38927b4–0x3892a3a(646 bytes) · SHA-25620d375a795c747277fad60482ed108536b359df2fc52888755fd9348d14f77e7
{
"type": "object",
"properties": {
"action": {
"type": "string",
"description": "Description or command of the proposed agent action being evaluated"
},
"target": {
"type": "string",
"description": "Target resource, URL, file, UI element, or recipient of the action"
},
"category": {
"type": "string",
"description": "Candidate Mango policy name or category (e.g., 'Comm-1', 'Data-1', 'Transaction-1 One-off Action', 'Platform-1')"
},
"history": {
"type": "string",
"description": "Brief summary of relevant actions executed so far in the trajectory"
}
},
"required": ["action"]
}
Embedded JSON tool schema (change_type, new_value)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x386ee8f–0x386efc0(305 bytes) · SHA-25634cbe9ad62ad939d52e77932641d219d40dbc7918861e08d1f6ca6cc66b8fe34
{
"type": "object",
"properties": {
"change_type": {
"type": "string",
"description": "Type of change: 'path', 'env_var', 'alias'"
},
"new_value": {
"type": "string",
"description": "The new value being set"
}
},
"required": ["change_type", "new_value"]
}
Embedded JSON tool schema (command_or_action, target, category, action_type)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x38bc261–0x38bc6b5(1,108 bytes) · SHA-2561084487afe9148552d15374fb945b2f1684be93578782fd7c8f9f25e04673611
{
"type": "object",
"properties": {
"command_or_action": {
"type": "string",
"description": "Complete, unmodified full command string (including all &&, ;, or | segments) or action description"
},
"target": {
"type": "string",
"description": "Exact target as written in the command: file path, URL, query, branch, remote, service, process, or resource"
},
"category": {
"type": "string",
"description": "Category: 'filesystem', 'vcs', 'deploy', 'database', 'cloud_storage', 'infrastructure', 'process', 'guardrail_config', 'constraint_violation'"
},
"action_type": {
"type": "string",
"description": "Action type: 'delete', 'truncate', 'wipe', 'force_push', 'push', 'deploy', 'drop', 'teardown', 'terminate', 'rollback'"
},
"recursive": {
"type": "boolean",
"description": "True if the operation is recursive, bulk, all, or cascade"
},
"force": {
"type": "boolean",
"description": "True if force flags are used (--force, -f, -D, --auto-approve, --yes, -9)"
}
},
"required": ["target"]
}
Embedded JSON tool schema (command_or_action, target, category, action_type) (2)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x38cd762–0x38cdc7a(1,304 bytes) · SHA-256a4865b13cc4b292a015421246e8618ccd8e017d53d8065907d8ba02614fed426
{
"type": "object",
"properties": {
"command_or_action": {
"type": "string",
"description": "Complete, unmodified full command string (including all &&, ;, or | segments) or action description"
},
"target": {
"type": "string",
"description": "Exact target as written in the command: file path, URL, query, branch, remote, service, process, script, recipient, job, or resource"
},
"category": {
"type": "string",
"description": "Category: 'filesystem', 'vcs', 'deploy', 'database', 'cloud_storage', 'infrastructure', 'process', 'messaging', 'publish', 'compute_cost', 'host_config', 'script_execution', 'inline_code', 'guardrail_config', 'constraint_violation'"
},
"action_type": {
"type": "string",
"description": "Action type: 'delete', 'truncate', 'wipe', 'force_push', 'push', 'deploy', 'drop', 'teardown', 'terminate', 'rollback', 'send', 'grant_access', 'publish', 'launch', 'provision', 'configure', 'execute'"
},
"recursive": {
"type": "boolean",
"description": "True if the operation is recursive, bulk, all, or cascade"
},
"force": {
"type": "boolean",
"description": "True if force flags are used (--force, -f, -D, --auto-approve, --yes, -9)"
}
},
"required": ["target"]
}
Embedded JSON tool schema (Path)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x385c7a5–0x385c870(203 bytes) · SHA-256e0cc87660f53435dc555182acc658d43fdb2d13db980fca70e71786d784a5728
{
"type": "object",
"properties": {
"Path": {
"type": "string",
"description": "Directory path to list (relative to the working directory or absolute)."
}
},
"required": ["Path"]
}
Embedded JSON tool schema (path, evidence)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x387e559–0x387e70d(436 bytes) · SHA-2565411d1965c83e6313f6fe2c1613224d36cf7d04b3d7b445e9b4f9490cf27b48d
{
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Absolute path of the new file or directory created directly inside a protected directory."
},
"evidence": {
"type": "string",
"description": "The exact part of the action that writes the new entry, quoted verbatim and naming it (e.g. 'touch out.txt', '> notes.md', 'mkdir tmp')."
}
},
"required": ["path", "evidence"]
}
Embedded JSON tool schema (Path, StartLine, EndLine)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x387d136–0x387d2dd(423 bytes) · SHA-2566b5ad7d1ff84fe80626fba1929b848c3ec6219e25541d07958924b308c2fd07b
{
"type": "object",
"properties": {
"Path": {
"type": "string",
"description": "Path to the file to read (relative to the working directory or absolute)."
},
"StartLine": {
"type": "integer",
"description": "Optional 1-indexed start line (inclusive)."
},
"EndLine": {
"type": "integer",
"description": "Optional 1-indexed end line (inclusive)."
}
},
"required": ["Path"]
}
Embedded JSON tool schema (schemaArray, nonNegativeInteger, stringArray, items)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x394123f–0x3941eba(3,195 bytes) · SHA-256bf7460259b94e8291eaeec1b077f98caff3d16df17ee2a99208f74f1412c4932
{
"$schema": "http://json-schema.org/draft-06/schema#",
"$id": "http://json-schema.org/draft-06/schema#",
"title": "Core schema meta-schema",
"definitions": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
},
"nonNegativeInteger": {
"type": "integer",
"minimum": 0
},
"nonNegativeIntegerDefault0": {
"allOf": [
{ "$ref": "#/definitions/nonNegativeInteger" },
{ "default": 0 }
]
},
"simpleTypes": {
"enum": [
"array",
"boolean",
"integer",
"null",
"number",
"object",
"string"
]
},
"stringArray": {
"type": "array",
"items": { "type": "string" },
"uniqueItems": true,
"default": []
}
},
"type": ["object", "boolean"],
"properties": {
"$id": {
"type": "string",
"format": "uri-reference"
},
"$schema": {
"type": "string",
"format": "uri"
},
"$ref": {
"type": "string",
"format": "uri-reference"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": {},
"multipleOf": {
"type": "number",
"exclusiveMinimum": 0
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "number"
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "number"
},
"maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
"minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
},
"additionalItems": { "$ref": "#" },
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": {}
},
"maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
"minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
},
"contains": { "$ref": "#" },
"maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
"minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": { "$ref": "#" },
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"dependencies": {
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/stringArray" }
]
}
},
"propertyNames": { "$ref": "#" },
"const": {},
"enum": {
"type": "array",
"minItems": 1,
"uniqueItems": true
},
"type": {
"anyOf": [
{ "$ref": "#/definitions/simpleTypes" },
{
"type": "array",
"items": { "$ref": "#/definitions/simpleTypes" },
"minItems": 1,
"uniqueItems": true
}
]
},
"format": { "type": "string" },
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
"default": {}
}
Embedded JSON tool schema (schemaArray, nonNegativeInteger, stringArray, items) (2)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x3955bf9–0x3956a41(3,656 bytes) · SHA-256943da3dc9a29dbfbd325aec2ca01cfd6304a1cd53fde2c9775bcca6523f6410e
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "http://json-schema.org/draft-07/schema#",
"title": "Core schema meta-schema",
"definitions": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
},
"nonNegativeInteger": {
"type": "integer",
"minimum": 0
},
"nonNegativeIntegerDefault0": {
"allOf": [
{ "$ref": "#/definitions/nonNegativeInteger" },
{ "default": 0 }
]
},
"simpleTypes": {
"enum": [
"array",
"boolean",
"integer",
"null",
"number",
"object",
"string"
]
},
"stringArray": {
"type": "array",
"items": { "type": "string" },
"uniqueItems": true,
"default": []
}
},
"type": ["object", "boolean"],
"properties": {
"$id": {
"type": "string",
"format": "uri-reference"
},
"$schema": {
"type": "string",
"format": "uri"
},
"$ref": {
"type": "string",
"format": "uri-reference"
},
"$comment": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": true,
"readOnly": {
"type": "boolean",
"default": false
},
"writeOnly": {
"type": "boolean",
"default": false
},
"examples": {
"type": "array",
"items": true
},
"multipleOf": {
"type": "number",
"exclusiveMinimum": 0
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "number"
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "number"
},
"maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
"minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
},
"additionalItems": { "$ref": "#" },
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": true
},
"maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
"minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
},
"contains": { "$ref": "#" },
"maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
"minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": { "$ref": "#" },
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"propertyNames": { "format": "regex" },
"default": {}
},
"dependencies": {
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/stringArray" }
]
}
},
"propertyNames": { "$ref": "#" },
"const": true,
"enum": {
"type": "array",
"items": true,
"minItems": 1,
"uniqueItems": true
},
"type": {
"anyOf": [
{ "$ref": "#/definitions/simpleTypes" },
{
"type": "array",
"items": { "$ref": "#/definitions/simpleTypes" },
"minItems": 1,
"uniqueItems": true
}
]
},
"format": { "type": "string" },
"contentMediaType": { "type": "string" },
"contentEncoding": { "type": "string" },
"if": { "$ref": "#" },
"then": { "$ref": "#" },
"else": { "$ref": "#" },
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
"default": true
}
Embedded JSON tool schema (schemaArray, positiveInteger, stringArray, items)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x3945da9–0x3946a5c(3,251 bytes) · SHA-2565e4a46b433800681b8da4911df61cd72212d5bce2839e1c772e2b99a89fbbf09
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Core schema meta-schema",
"definitions": {
"schemaArray": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#" }
},
"positiveInteger": {
"type": "integer",
"minimum": 0
},
"positiveIntegerDefault0": {
"allOf": [ { "$ref": "#/definitions/positiveInteger" }, { "default": 0 } ]
},
"simpleTypes": {
"enum": [ "array", "boolean", "integer", "null", "number", "object", "string" ]
},
"stringArray": {
"type": "array",
"items": { "type": "string" },
"minItems": 1,
"uniqueItems": true
}
},
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uriref"
},
"$schema": {
"type": "string",
"format": "uri"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": {},
"multipleOf": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "boolean",
"default": false
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "boolean",
"default": false
},
"maxLength": { "$ref": "#/definitions/positiveInteger" },
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
"pattern": {
"type": "string",
"format": "regex"
},
"additionalItems": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
},
"items": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/schemaArray" }
],
"default": {}
},
"maxItems": { "$ref": "#/definitions/positiveInteger" },
"minItems": { "$ref": "#/definitions/positiveIntegerDefault0" },
"uniqueItems": {
"type": "boolean",
"default": false
},
"maxProperties": { "$ref": "#/definitions/positiveInteger" },
"minProperties": { "$ref": "#/definitions/positiveIntegerDefault0" },
"required": { "$ref": "#/definitions/stringArray" },
"additionalProperties": {
"anyOf": [
{ "type": "boolean" },
{ "$ref": "#" }
],
"default": {}
},
"definitions": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"properties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"patternProperties": {
"type": "object",
"additionalProperties": { "$ref": "#" },
"default": {}
},
"dependencies": {
"type": "object",
"additionalProperties": {
"anyOf": [
{ "$ref": "#" },
{ "$ref": "#/definitions/stringArray" }
]
}
},
"enum": {
"type": "array",
"minItems": 1,
"uniqueItems": true
},
"type": {
"anyOf": [
{ "$ref": "#/definitions/simpleTypes" },
{
"type": "array",
"items": { "$ref": "#/definitions/simpleTypes" },
"minItems": 1,
"uniqueItems": true
}
]
},
"allOf": { "$ref": "#/definitions/schemaArray" },
"anyOf": { "$ref": "#/definitions/schemaArray" },
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" },
"format": { "type": "string" },
"$ref": { "type": "string" }
},
"dependencies": {
"exclusiveMaximum": [ "maximum" ],
"exclusiveMinimum": [ "minimum" ]
},
"default": {}
}
Embedded JSON tool schema (source, destination, data_type, intent)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x38e9ce4–0x38ea380(1,692 bytes) · SHA-256ce10786a2f66a33c59aeb83bf9e204d9dca5df429bd13c6b6dd61e049969d924
{
"type": "object",
"properties": {
"source": {
"type": "string",
"description": "Source of data: URL, file path, or 'local'"
},
"destination": {
"type": "string",
"description": "Destination: URL, file path, or 'local'"
},
"data_type": {
"type": "string",
"description": "Type: 'any', 'secrets', 'infrastructure', 'code'"
},
"intent": {
"type": "string",
"description": "Intent: 'read', 'persist', 'transmit', 'execute', 'delete', 'other'"
},
"upload_data_in_domain": {
"type": "boolean",
"description": "True if local data (file contents, environment variables, command output) may be exfiltrated via URL subdomains or query params. Not for literal search terms or API filters."
},
"uri_contains_data": {
"type": "boolean",
"description": "True if the URI query parameters or inline request body itself embeds sensitive/private data from the conversation (not literal public search queries, bounding boxes, or API filter syntax)"
},
"secret_in_header": {
"type": "boolean",
"description": "True if a secret or credential is passed in an HTTP request header (e.g. Authorization, X-API-Key, x-goog-api-key, or curl -u). Indicates a credential is present in a header, not that the header is the only place data appears."
},
"source_in_downloaded_path": {
"type": "boolean",
"description": "Set to true if the source path resides inside a previously downloaded directory listed in env_state.untrusted_downloads, or was moved/copied/symlinked/aliased from such a path."
}
},
"required": ["source", "destination", "data_type", "intent"]
}
Embedded JSON tool schema (title, description, deprecated, readOnly)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x3897331–0x38975e2(689 bytes) · SHA-256a72a0fbc2272d9effcc71a159f9c92f0ef4417c0f1677f515767de77b5238a0a
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://json-schema.org/draft/2019-09/meta/meta-data",
"$vocabulary": {
"https://json-schema.org/draft/2019-09/vocab/meta-data": true
},
"$recursiveAnchor": true,
"title": "Meta-data vocabulary meta-schema",
"type": ["object", "boolean"],
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": true,
"deprecated": {
"type": "boolean",
"default": false
},
"readOnly": {
"type": "boolean",
"default": false
},
"writeOnly": {
"type": "boolean",
"default": false
},
"examples": {
"type": "array",
"items": true
}
}
}
Embedded JSON tool schema (title, description, deprecated, readOnly) (2)
When: JSON Schema object embedded in language_server rodata.
- Source:
desktop/Contents/Resources/bin/language_server@0x3898bdc–0x3898eae(722 bytes) · SHA-256e070588fd8fac3a0b4bed1dbe1f576ccdb2e32ade3b46bd590150d0b15506859
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://json-schema.org/draft/2020-12/meta/meta-data",
"$vocabulary": {
"https://json-schema.org/draft/2020-12/vocab/meta-data": true
},
"$dynamicAnchor": "meta",
"title": "Meta-data vocabulary meta-schema",
"type": ["object", "boolean"],
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"default": true,
"deprecated": {
"type": "boolean",
"default": false
},
"readOnly": {
"type": "boolean",
"default": false
},
"writeOnly": {
"type": "boolean",
"default": false
},
"examples": {
"type": "array",
"items": true
}
}
}
Embedded Python runner: run_workflow
When: Embedded Python runtime harness executed by the run_workflow tool.
- Source:
desktop/Contents/Resources/bin/language_server@0x3b6f97e–0x3b75f9b(26,141 bytes) · SHA-256308b0f30578eadb3dab8945e82e17e2213b54ecb82c57eead92f19e8c210a2aa
# Runs a run_workflow script with the primitives in _PRIMITIVES (plus call_tool
# when the init message enables it), which proxy to Go as JSON lines over stdout
# (requests and notifications) and stdin (replies).
# Requests carry an "id" that their reply echoes; log/phase/start/kill are
# id-less notifications, sent in call order.
import ast
import asyncio
import contextvars
import importlib.abc
import importlib.util
import inspect
import itertools
import json
import linecache
import math
import os
import sys
import threading
import traceback
import weakref
# Library workflows are loaded from sources sent by Go; don't write .pyc files.
sys.dont_write_bytecode = True
# The RPC uses private, non-inheritable copies of fd 0 and 1. Fd 0 becomes
# /dev/null and fd 1 a copy of stderr, so neither the script nor its child
# processes can corrupt the RPC.
_rpc_in = os.fdopen(os.dup(0), "r", encoding="utf-8")
_rpc_out = os.fdopen(os.dup(1), "w", encoding="utf-8")
_null = os.open(os.devnull, os.O_RDONLY)
os.dup2(_null, 0)
os.close(_null)
os.dup2(2, 1)
# Keep scripts off the RPC pipes; stdin reads fail fast with EOFError.
sys.stdin = open(os.devnull)
sys.stdout = sys.stderr
_ids = itertools.count(1)
_agent_ids = itertools.count(1)
_agent_uids = itertools.count(1)
# Futures of in-flight requests, by request id. Only touched on the event loop.
_pending = {}
# Every turn and call_tool promise created, to catch ones the script never
# awaits.
_tracked = []
# Weak references to every agent, so `del a` really drops it, plus the labels of
# agents dropped before the script ended without ever running.
_agents = []
_unused = []
# The script's event loop, once it runs.
_loop = None
class WorkflowError(Exception):
pass
class BudgetExceeded(WorkflowError): # pylint: disable=g-bad-exception-name
"""A token, agent-count, or wall-clock budget was exceeded."""
class ToolError(WorkflowError):
"""A failed or denied call_tool call.
.denied is True when a pre-tool hook or the permission check rejected the
call before the tool ran.
"""
def __init__(self, tool, message, denied=False):
super().__init__("%s: %s" % (tool, message))
self.tool = tool
self.message = message
self.denied = denied
def _send(msg):
_rpc_out.write(json.dumps(msg) + "\n")
_rpc_out.flush()
def _resolve(reply):
fut = _pending.pop(reply.get("id"), None)
if fut is None or fut.done():
return
if reply.get("error"):
err = WorkflowError(reply["error"])
err.denied = bool(reply.get("denied"))
fut.set_exception(err)
else:
fut.set_result(reply.get("result"))
def _read_replies(loop):
for line in _rpc_in:
reply = json.loads(line)
try:
loop.call_soon_threadsafe(_resolve, reply)
except RuntimeError: # The loop has closed.
return
# Go closed the pipe: the workflow is over.
os._exit(1)
async def _request(op, **payload):
rid = next(_ids)
fut = asyncio.get_running_loop().create_future()
_pending[rid] = fut
payload["op"] = op
payload["id"] = rid
_send(payload)
try:
return await fut
except asyncio.CancelledError:
# Nobody awaits the result anymore (e.g. a failed parallel() sibling).
if _pending.pop(rid, None) is not None:
_notify("cancel", id=rid)
raise
def _notify(op, **payload):
payload["op"] = op
_send(payload)
class _Promise:
"""A lazy awaitable: its work starts on the first await and runs once."""
_task = None
_awaited = False
def __await__(self):
self._awaited = True
if self._task is None:
self._task = asyncio.ensure_future(self._run())
return self._task.__await__()
async def _run(self):
raise NotImplementedError
class _ToolPromise(_Promise):
def __init__(self, name, args):
self._name = name
self._args = args
_tracked.append(self)
def __repr__(self):
return "call_tool(%r)" % self._name
def _label(self):
return repr(self)
async def _run(self):
try:
return await _request("call_tool", name=self._name, args=self._args)
except WorkflowError as e:
raise ToolError(
self._name, str(e), getattr(e, "denied", False)
) from None
def call_tool(name, **args):
"""Returns a promise; awaiting it runs the tool and returns its output."""
if not isinstance(name, str) or not name:
raise ValueError("call_tool: name must be a non-empty string")
return _ToolPromise(name, args)
def log(*args):
if not args:
raise TypeError("log: requires at least 1 argument")
_notify("log", message=" ".join(str(a) for a in args))
def phase(name):
_notify("phase", name=str(name))
return name
_WORKSPACES = ("inherit", "branch", "share")
def _schema_json(schema):
if schema is None or schema == "":
raise ValueError("agent: schema is required")
return schema if isinstance(schema, str) else json.dumps(schema)
def _check_prompt(prompt):
if not isinstance(prompt, str) or not prompt.strip():
raise ValueError("agent: prompt must be a non-empty string")
return prompt
def _snippet(text):
text = text.strip().splitlines()[0]
return text[:40] + "..." if len(text) > 40 else text
def _zero_tokens():
return {
"input_tokens": 0,
"output_tokens": 0,
"cache_read_tokens": 0,
"total_tokens": 0,
}
def _add_tokens(dst, src):
in_tok = int(src.get("input_tokens", 0))
out_tok = int(src.get("output_tokens", 0))
cache_tok = int(src.get("cache_read_tokens", 0))
tot_tok = int(src.get("total_tokens", in_tok + out_tok + cache_tok))
dst["input_tokens"] += in_tok
dst["output_tokens"] += out_tok
dst["cache_read_tokens"] += cache_tok
dst["total_tokens"] += tot_tok
_workflow_tokens = _zero_tokens()
_ACTIVE_BUDGET_SCOPES = contextvars.ContextVar(
"workflow_budget_scopes", default=()
)
def _charge_agent_to_scopes(agent_obj, scopes):
"""Charges agent_obj once against each budget scope in scopes."""
if not scopes:
return
aid = agent_obj._uid # pylint: disable=protected-access
to_charge = [
s for s in scopes if aid not in s._charged_agents # pylint: disable=protected-access
]
for s in to_charge:
if s.max_agents is not None and s.created >= s.max_agents:
raise BudgetExceeded("budget of %d agent(s) spent" % s.max_agents)
for s in to_charge:
s._charged_agents.add(aid) # pylint: disable=protected-access
s.created += 1
def _charge_active_agent(agent_obj):
_charge_agent_to_scopes(agent_obj, _ACTIVE_BUDGET_SCOPES.get())
def _charge_active_tokens(usage, owner_agent=None):
"""Accumulates token usage and raises BudgetExceeded on cap breach."""
if not isinstance(usage, dict):
return
_add_tokens(_workflow_tokens, usage)
if owner_agent is not None:
_add_tokens(owner_agent._tokens, usage) # pylint: disable=protected-access
scopes = _ACTIVE_BUDGET_SCOPES.get()
exceeded = None
for s in scopes:
_add_tokens(s._tokens, usage) # pylint: disable=protected-access
if (
exceeded is None
and s.max_tokens is not None
and s._tokens["total_tokens"] > s.max_tokens # pylint: disable=protected-access
):
exceeded = s.max_tokens
if exceeded is not None:
raise BudgetExceeded("budget of %d token(s) spent" % exceeded)
def _unwrap_agent_result(raw, owner_agent=None):
if (
isinstance(raw, dict)
and "__workflow_result__" in raw
and "__workflow_tokens__" in raw
):
_charge_active_tokens(raw["__workflow_tokens__"], owner_agent)
return raw["__workflow_result__"]
return raw
class _Agent:
"""An agent: `await a` runs it once; `await a(prompt, schema)` runs one turn.
The two are exclusive. A multi-use agent lives until `del a` or the end of
the workflow.
"""
_spec = None
_mode = None # "single" once awaited, "multi" once called.
_task = None # The single-use run.
_id = None
_tokens = None
def __init__(
self,
prompt,
schema,
role,
type_name,
workspace,
model=None,
):
if prompt is not None:
_check_prompt(prompt)
if schema is not None:
schema = _schema_json(schema)
if role is not None and not isinstance(role, str):
raise ValueError("agent: role must be a string")
if model is not None and not isinstance(model, str):
raise ValueError("agent: model must be a string")
if not isinstance(type_name, str) or not type_name:
raise ValueError("agent: type_name must be a non-empty string")
if workspace not in _WORKSPACES:
raise ValueError(
"agent: workspace must be 'inherit', 'branch', or 'share', got %r"
% (workspace,)
)
self._uid = next(_agent_uids)
_charge_active_agent(self)
self._tokens = _zero_tokens()
self._spec = {
"prompt": prompt,
"schema": schema,
"role": role or "",
"type_name": type_name,
"workspace": workspace,
"model": model,
}
_agents.append(weakref.ref(self))
def __repr__(self):
return self._label()
def _label(self):
if self._spec["prompt"] is not None:
return "agent(%r)" % _snippet(self._spec["prompt"])
if self._spec["role"]:
return "agent(role=%r)" % self._spec["role"]
return "agent()"
async def _run_single(self):
raw = await _request("agent", spec=self._spec)
return _unwrap_agent_result(raw, self)
def __await__(self):
if self._mode == "multi":
raise TypeError(
"%s was called for turns, so it cannot be awaited as a single-use"
" agent; await its calls instead"
% self._label()
)
if self._spec["prompt"] is None:
raise TypeError(
"%s has no prompt to run; call it for a turn: await a(prompt, schema)"
% self._label()
)
if self._spec["schema"] is None:
raise ValueError("agent: schema is required")
self._mode = "single"
if self._task is None:
_charge_active_agent(self)
self._task = asyncio.ensure_future(self._run_single())
return self._task.__await__()
def __call__(self, prompt, schema=None):
"""Returns a promise; awaiting it runs one turn and returns its result."""
if self._mode == "single":
raise TypeError(
"%s was awaited, which ran it once and ended it; it cannot be"
" called for turns"
% self._label()
)
spec = {
"prompt": _check_prompt(prompt),
"schema": _schema_json(
self._spec["schema"] if schema is None else schema
),
}
if self._mode is None:
_charge_active_agent(self)
self._mode = "multi"
self._id = next(_agent_ids)
start = dict(self._spec, prompt=self._spec["prompt"] or "")
del start["schema"] # Each turn brings its own.
_notify("start", agent=self._id, spec=start)
return _TurnPromise(self, spec)
def __del__(self):
try:
if self._mode == "multi":
# May run mid-write or on the reader thread, so send from the loop.
_loop.call_soon_threadsafe(_notify_kill, self._id)
elif self._mode is None and self._spec["prompt"] is not None:
_unused.append(self._label())
except Exception:
# Interpreter teardown, or the loop is closed: Go kills every agent
# when the workflow ends.
pass
def _notify_kill(agent_id):
_notify("kill", agent=agent_id)
class _TurnPromise(_Promise):
"""One turn of a multi-use agent.
Holds the agent weakly so `del a` ends it.
"""
def __init__(self, agent, spec):
self._agent = weakref.ref(agent)
self._owner = agent._label()
self._spec = spec
_tracked.append(self)
def __repr__(self):
return "%s(%r)" % (self._owner, self._spec["prompt"])
def _label(self):
return "%s(%r)" % (self._owner, _snippet(self._spec["prompt"]))
async def _run(self):
a = self._agent()
if a is None:
raise WorkflowError("%s was deleted" % self._owner)
_charge_active_agent(a)
agent_id = a._id
del a # Keep the frame from holding the agent across the await.
raw = await _request("turn", agent=agent_id, spec=self._spec)
return _unwrap_agent_result(raw, self._agent())
def agent(
prompt=None,
schema=None,
role=None,
type_name="self",
workspace="inherit",
model=None,
):
"""Defines an agent; `await agent(prompt, schema)` runs it once.
Calling it instead, `await a(prompt, schema)`, runs one turn in a
conversation that lasts across calls; `prompt` is then its standing
instructions.
"""
return _Agent(prompt, schema, role, type_name, workspace, model)
def _awaitable(fn_name, value):
if not inspect.isawaitable(value):
raise TypeError(
"%s: fn must return an awaitable such as agent(...), got %s"
% (fn_name, type(value).__name__)
)
return value
class _ParallelPromise(_Promise):
def __init__(self, items, fn):
self._items = items
self._fn = fn
async def _run(self):
tasks = []
values = []
try:
for item in self._items:
value = _awaitable("parallel", self._fn(item))
values.append(value)
tasks.append(asyncio.ensure_future(value))
return list(await asyncio.gather(*tasks))
except BaseException:
# One failed (or we were cancelled): stop the siblings, and mark agents
# whose task never started as handled so they aren't reported unawaited.
for v in values:
if not inspect.iscoroutine(v):
_discard_awaitable(v)
for t in tasks:
t.cancel()
raise
class _PipelinePromise(_Promise):
def __init__(self, items, fn):
self._items = items
self._fn = fn
async def _run(self):
results = []
for item in self._items:
results.append(await _awaitable("pipeline", self._fn(item)))
return results
def _check_map_args(fn_name, items, fn):
if not callable(fn):
raise TypeError("%s: fn must be callable" % fn_name)
return list(items)
def parallel(items, fn):
"""Returns a promise of [await fn(item) for item in items], run concurrently."""
return _ParallelPromise(_check_map_args("parallel", items, fn), fn)
def pipeline(items, fn):
"""Returns a promise of [await fn(item) for item in items], run one by one."""
return _PipelinePromise(_check_map_args("pipeline", items, fn), fn)
class _BudgetScope:
"""Tracks token and agent consumption inside a with_budget execution scope."""
def __init__(self, max_tokens=None, max_agents=None, max_seconds=None):
self.max_tokens = max_tokens
self.max_agents = max_agents
self.max_seconds = max_seconds
self.created = 0
self._uid = next(_agent_uids)
self._tokens = _zero_tokens()
self._charged_agents = set()
@property
def remaining(self):
if self.max_agents is None:
return None
return max(0, self.max_agents - self.created)
@property
def remaining_tokens(self):
if self.max_tokens is None:
return None
return max(0, self.max_tokens - self._tokens["total_tokens"])
def agent(self, *args, **kwargs):
a = agent(*args, **kwargs)
_charge_agent_to_scopes(a, (self,))
return a
def tokens_used(agent_or_scope=None):
"""Returns token usage dict for the workflow, an agent, or a budget scope."""
if agent_or_scope is None:
return dict(_workflow_tokens)
target = agent_or_scope
while hasattr(target, "_target"):
target = target._target # pylint: disable=protected-access
if isinstance(target, (_Agent, _BudgetScope)):
return dict(target._tokens) # pylint: disable=protected-access
raise TypeError(
"tokens_used: expected an agent, budget scope, or None, got %s"
% type(agent_or_scope).__name__
)
def _discard_awaitable(awaitable):
while hasattr(awaitable, "_target"):
awaitable = awaitable._target # pylint: disable=protected-access
if inspect.iscoroutine(awaitable):
awaitable.close()
elif hasattr(awaitable, "_awaited"):
awaitable._awaited = True # pylint: disable=protected-access
elif getattr(awaitable, "_mode", None) is None and hasattr(
awaitable, "_spec"
):
awaitable._mode = "single" # pylint: disable=protected-access
def _callable_arity(fn):
try:
params = inspect.signature(fn).parameters.values()
except (TypeError, ValueError):
return 0
if any(p.kind == inspect.Parameter.VAR_POSITIONAL for p in params):
return 1
return sum(
p.kind
in (
inspect.Parameter.POSITIONAL_ONLY,
inspect.Parameter.POSITIONAL_OR_KEYWORD,
)
for p in params
)
async def with_budget(
awaitable,
max_tokens=None,
max_agents=None,
max_seconds=None,
*,
timeout=None,
):
"""Awaits awaitable (or calls fn) under token, agent-count, and time caps."""
if max_tokens is not None and (
isinstance(max_tokens, bool)
or not isinstance(max_tokens, int)
or max_tokens < 1
):
_discard_awaitable(awaitable)
raise ValueError("with_budget: max_tokens must be a positive integer")
if max_agents is not None and (
isinstance(max_agents, bool)
or not isinstance(max_agents, int)
or max_agents < 1
):
_discard_awaitable(awaitable)
raise ValueError("with_budget: max_agents must be a positive integer")
if max_seconds is not None and timeout is not None:
_discard_awaitable(awaitable)
raise ValueError("with_budget: set at most one of max_seconds and timeout")
seconds = max_seconds if max_seconds is not None else timeout
if seconds is not None and (
isinstance(seconds, bool)
or not isinstance(seconds, (int, float))
or not math.isfinite(seconds)
or seconds <= 0
):
_discard_awaitable(awaitable)
raise ValueError("with_budget: timeout must be a positive number")
if not inspect.isawaitable(awaitable) and not callable(awaitable):
raise TypeError(
"with_budget: expected an awaitable or callable, got %s"
% type(awaitable).__name__
)
scope = _BudgetScope(
max_tokens=max_tokens,
max_agents=max_agents,
max_seconds=seconds,
)
async def _exec():
token = _ACTIVE_BUDGET_SCOPES.set((*_ACTIVE_BUDGET_SCOPES.get(), scope))
try:
target = awaitable
if callable(target) and not inspect.isawaitable(target):
target = target(scope) if _callable_arity(target) >= 1 else target()
if not inspect.isawaitable(target):
raise TypeError(
"with_budget: callable must return an awaitable, got %s"
% type(target).__name__
)
res = await target
finally:
_ACTIVE_BUDGET_SCOPES.reset(token)
if (
max_tokens is not None
and scope._tokens["total_tokens"] > max_tokens # pylint: disable=protected-access
):
raise BudgetExceeded("budget of %d token(s) spent" % max_tokens)
return res
if seconds is None:
return await _exec()
try:
return await asyncio.wait_for(_exec(), timeout=seconds)
except (asyncio.TimeoutError, TimeoutError):
raise BudgetExceeded("budget of %s s exceeded" % seconds) from None
class Step(dict):
"""A trajectory step: a dict that also supports attribute access."""
def __getattr__(self, name):
if name.startswith("__"):
raise AttributeError(name)
return self.get(name)
def _str_list(name, value):
if value is None:
return None
if isinstance(value, str) or not all(isinstance(v, str) for v in value):
raise ValueError("trajectory: %s must be a list of strings" % name)
return list(value)
def _non_neg_int(name, value):
if value is None:
return None
if isinstance(value, bool) or not isinstance(value, int) or value < 0:
raise ValueError("trajectory: %s must be a non-negative integer" % name)
return value
async def trajectory(
last=None, types=None, tools=None, min_index=None, max_index=None
):
"""Returns the conversation's steps before this workflow, oldest first.
Each Step has index, type, status, and either text (messages) or tool, args
and output (tool calls). min_index and max_index bound step.index (inclusive);
types (e.g. "USER_INPUT", "PLANNER_RESPONSE") and tools (e.g. "run_command")
filter; last keeps the last N matching steps.
"""
if last is not None and (
isinstance(last, bool) or not isinstance(last, int) or last < 1
):
raise ValueError("trajectory: last must be a positive integer")
args = {
"last": last,
"types": _str_list("types", types),
"tools": _str_list("tools", tools),
"min_index": _non_neg_int("min_index", min_index),
"max_index": _non_neg_int("max_index", max_index),
}
steps = await _request(
"trajectory", args={k: v for k, v in args.items() if v is not None}
)
return [Step(s) for s in steps]
_PRIMITIVES = {
"log": log,
"phase": phase,
"agent": agent,
"parallel": parallel,
"pipeline": pipeline,
"trajectory": trajectory,
"tokens_used": tokens_used,
"with_budget": with_budget,
"BudgetExceeded": BudgetExceeded,
}
class _LibraryFinder(importlib.abc.MetaPathFinder, importlib.abc.Loader):
"""Imports library workflows from their sources, with the script's primitives.
A library's top-level module is its __init__.py or <name>.py; its other
files are submodules, e.g. util.py is <name>.util.
"""
def __init__(self, libraries, primitives):
self._libraries = libraries
self._primitives = primitives
def find_spec(self, fullname, path=None, target=None):
name, _, sub = fullname.partition(".")
files = self._libraries.get(name)
if files is None:
return None
if sub:
rel = sub.replace(".", "/")
candidates = [(rel + "/__init__.py", True), (rel + ".py", False)]
else:
candidates = [("__init__.py", True), (name + ".py", True)]
for file, is_package in candidates:
if file in files:
spec = importlib.util.spec_from_loader(
fullname, self, origin=file, is_package=is_package
)
spec.loader_state = (name, file)
return spec
return None
def create_module(self, spec):
return None
def exec_module(self, module):
name, file = module.__spec__.loader_state
module.__dict__.update(self._primitives)
filename = "<workflow library %s/%s>" % (name, file)
exec(
compile(self._libraries[name][file], filename, "exec"), module.__dict__
)
# Frames of the script kept in an error's traceback, most recent last.
_MAX_TRACEBACK_FRAMES = 20
def _script_traceback(exc):
"""Returns exc's traceback through the script's own frames, or ""."""
frames = [
f
for f in traceback.extract_tb(exc.__traceback__)
if f.filename == "<workflow>"
]
if not frames:
return ""
lines = ["Traceback (most recent call last):\n"]
if len(frames) > _MAX_TRACEBACK_FRAMES:
lines.append(
" ... %d earlier frames\n" % (len(frames) - _MAX_TRACEBACK_FRAMES)
)
frames = frames[-_MAX_TRACEBACK_FRAMES:]
for f in frames:
lines.append(' File "<workflow>", line %d, in %s\n' % (f.lineno, f.name))
if f.line:
lines.append(" %s\n" % f.line.strip())
return "".join(lines).rstrip("\n")
def _script_line(exc):
line = None
tb = exc.__traceback__
while tb is not None:
if tb.tb_frame.f_code.co_filename == "<workflow>":
line = tb.tb_lineno
tb = tb.tb_next
return line
async def _eval(code, scope):
value = eval(code, scope)
if code.co_flags & inspect.CO_COROUTINE:
value = await value
return value
async def _run_script(code, trailing, scope):
global _loop
_loop = asyncio.get_running_loop()
threading.Thread(
target=_read_replies, args=(asyncio.get_running_loop(),), daemon=True
).start()
await _eval(code, scope)
if trailing is not None:
# Like a notebook cell, print a trailing expression's repr.
value = await _eval(trailing, scope)
if value is not None:
print(repr(value))
def _end(msg):
# Go stops the interpreter on the terminal message; flush what it printed.
sys.stderr.flush()
_send(msg)
def _main():
init = json.loads(_rpc_in.readline())
# Lets tracebacks show the script's source lines.
linecache.cache["<workflow>"] = (
len(init["script"]),
None,
init["script"].splitlines(True),
"<workflow>",
)
try:
tree = ast.parse(init["script"], "<workflow>")
trailing_expr = None
if tree.body and isinstance(tree.body[-1], (ast.Expr, ast.Return)):
trailing_expr = tree.body.pop().value
code = compile(
tree, "<workflow>", "exec", flags=ast.PyCF_ALLOW_TOP_LEVEL_AWAIT
)
trailing = None
if trailing_expr is not None:
trailing = compile(
ast.Expression(trailing_expr),
"<workflow>",
"eval",
flags=ast.PyCF_ALLOW_TOP_LEVEL_AWAIT,
)
except SyntaxError as e:
_end({"op": "error", "error": "workflow syntax error: %s" % e})
return
scope = dict(_PRIMITIVES)
scope["args"] = init.get("args") or {}
scope.update(init.get("context") or {})
scope["WORKSPACES"] = tuple(scope.get("WORKSPACES") or ())
if init.get("call_tool"):
scope["call_tool"] = call_tool
scope["ToolError"] = ToolError
# Appended, so a library can't shadow the standard library.
sys.meta_path.append(_LibraryFinder(init.get("libraries") or {}, dict(scope)))
try:
asyncio.run(_run_script(code, trailing, scope))
except (Exception, asyncio.CancelledError) as e:
line = _script_line(e)
where = " (line %d)" % line if line else ""
error = "workflow execution failed%s: %s: %s" % (where, type(e).__name__, e)
tb = _script_traceback(e)
if tb:
error += "\n" + tb
_end({"op": "error", "error": error})
return
unused = [p._label() for p in _tracked if not p._awaited]
for ref in _agents:
a = ref()
if a is not None and a._mode is None and a._spec["prompt"] is not None:
unused.append(a._label())
if unused or _unused:
_end({
"op": "error",
"error": (
"workflow execution failed: %s was never awaited"
% (unused + _unused)[0]
),
})
return
_end({"op": "done"})
_main()
Tool description: swarm
When: Native swarm management tool description exposed when swarm mode is enabled.
- Source:
desktop/Contents/Resources/bin/language_server@0x38bcf62–0x38bd3ba(1,112 bytes) · SHA-256406305c7490ea5bae6f628a8e0627fe90d0c869a1bfe6d7083cd2121100814a5
Manage the swarm of agents working with you on the shared message board. ONLY call this tool when the user explicitly invoked `/swarm`, a skill you read explicitly instructs you to call it, or this conversation already has an active swarm. NEVER start or inspect a swarm on your own (do not call `add`, `title`, `status`, or `models` unprompted); use `invoke_subagent` for normal subagent delegation instead. Actions: `add` spawns a worker under a roster name (or `<name>-1`..`<name>-<k>` when `tasks` or `n` is set), pinned to a model, and posts `brief` on the board as an @mention of it, which is where the swarm sees its assignment -- by default a worker starts fresh and sees nothing of this conversation, so the brief must say what it owns and what done looks like; pass `fork:"<member>"` (or `"coordinator"`) to branch the new worker from that member's conversation history instead. `workspace:"share"` gives each worker its own working copy of your repository, for authors who edit or build at the same time as others; `"branch"` gives an isolated clone; readers and verifiers keep the default `inherit`.