> ## Documentation Index
> Fetch the complete documentation index at: https://docs.guild.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent self-identification

> Retrieve the calling agent's own identity before posting to external systems.

`guildai~get_self` returns the calling agent's own identity — agent details, running version, session context, and workspace — in a single idempotent call. No parameters are required; the runtime resolves identity automatically from execution context.

The primary use case is attribution: call `guildai_get_self` just before posting to an external system — a pull request comment, Slack message, or Jira ticket — to attach accurate source information without threading identity details through prompts or agent inputs.

```typescript theme={null}
const self = await task.tools.guildai_get_self({})
```

`guildai_get_self` is automatically available to every running agent. No tool set import or credential configuration is required.

## Response payload

| Field       | Type           | Description                                                                                                 |
| ----------- | -------------- | ----------------------------------------------------------------------------------------------------------- |
| `agent`     | object \| null | Agent details. Null when the session is running under the built-in assistant rather than a published agent. |
| `version`   | object \| null | Agent version details. Null when the session is running under the built-in assistant.                       |
| `session`   | object         | Current session details.                                                                                    |
| `workspace` | object         | Current workspace details.                                                                                  |

### `agent` fields

| Field                | Type           | Description                                                                                                          |
| -------------------- | -------------- | -------------------------------------------------------------------------------------------------------------------- |
| `id`                 | string         | Agent ID.                                                                                                            |
| `name`               | string         | Agent name.                                                                                                          |
| `full_name`          | string         | Agent full name in `owner~name` format.                                                                              |
| `is_public`          | boolean        | Whether the agent is publicly visible.                                                                               |
| `public_profile_url` | string \| null | URL to the agent's public profile page (`{FRONTEND_URL}/hub/agents/{owner}~{name}`). Null when the agent is private. |
| `owner`              | object         | Agent owner. See [owner fields](#owner-fields).                                                                      |

### `version` fields

| Field            | Type           | Description                                                |
| ---------------- | -------------- | ---------------------------------------------------------- |
| `id`             | string         | Version ID.                                                |
| `status`         | string         | Publication status: `DRAFT`, `PUBLISHING`, or `PUBLISHED`. |
| `version_number` | string \| null | Version number. Null when `status` is `DRAFT`.             |

### `session` fields

| Field           | Type   | Description                                               |
| --------------- | ------ | --------------------------------------------------------- |
| `id`            | string | Session ID.                                               |
| `session_type`  | string | Session type: `chat`, `agent_test`, `time`, or `webhook`. |
| `session_url`   | string | URL to the current session in the Guild UI.               |
| `workspace_url` | string | URL to the current workspace in the Guild UI.             |

### `workspace` fields

| Field       | Type   | Description                                         |
| ----------- | ------ | --------------------------------------------------- |
| `id`        | string | Workspace ID.                                       |
| `name`      | string | Workspace name.                                     |
| `full_name` | string | Workspace full name in `owner/workspace` format.    |
| `owner`     | object | Workspace owner. See [owner fields](#owner-fields). |

### `owner` fields

Both `agent.owner` and `workspace.owner` share this shape.

| Field  | Type   | Description                           |
| ------ | ------ | ------------------------------------- |
| `id`   | string | Owner ID.                             |
| `type` | string | Owner type: `user` or `organization`. |
| `name` | string | Owner name.                           |

## Attribution example

Call `guildai_get_self` once at the start of any run that will post to an external service, then reuse the result for each outbound action:

```typescript theme={null}
import { gitHubTools } from "@guildai-services/guildai~github"
import { slackTools } from "@guildai-services/guildai~slack"

// ...

const self = await task.tools.guildai_get_self({})

// Build a reusable attribution link
const attribution = self.agent
  ? `[${self.agent.full_name}](${self.session.session_url})`
  : `[Guild Assistant](${self.session.session_url})`

// Post a GitHub PR comment attributed to this agent
await task.tools.github_issues_create_comment({
  owner: "myorg",
  repo: "myrepo",
  issue_number: prNumber,
  body: `Review complete — posted by ${attribution}.`,
})

// Post a Slack message attributed to this agent
await task.tools.slack_chat_postMessage({
  channel: "#deploys",
  text: `Deploy triggered by ${attribution} in workspace \`${self.workspace.full_name}\`.`,
})
```

<Tip>
  `guildai_get_self` is cheap and idempotent. Call it once per run and reuse the result across all external actions in the same agent invocation.
</Tip>
