# Query the current agent configuration

Read the configuration view of the specified agent version in the current system.

```text
GET https://moi.matrixorigin.cn/newmoi/workspaces/{workspace_id}/agent-builder/agents/{agent_id}/versions/{version}/current-agent
```

## Preparation before calling

First [confirm the agent candidate](commit-candidate.md), use `load_version` in the response as `version`, do not infer based on the candidate version. Prepare a personal access token with access to the target workspace, target workspace ID, agent ID, and version ID.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Target workspace ID, passed through the `X-Workspace-ID` Header and also as `workspace_id` in the path.
- `$AGENT_ID`: Agent ID, as `agent_id` in the path.
- `$VERSION`: The version identifier to query, as `version` in the path; use `load_version` in the confirmation candidate response.

## Request example

```bash
curl "https://moi.matrixorigin.cn/newmoi/workspaces/$WORKSPACE_ID/agent-builder/agents/$AGENT_ID/versions/$VERSION/current-agent" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `workspace_id` | string | Yes | Workspace ID. |
| `agent_id` | string | Yes | Agent ID. |
| `version` | string | Yes | Version identifier. |

## Query parameters

| Parameters | Type | Is it required | Description |
| --- | --- | --- | --- |
| `agent_workspace_id` | string | No | The workspace to which the agent version belongs. If not provided, the current workspace is used; only the current workspace or the system workspace can be specified. |

## Successful response

Returns `200` on success. Use `load_version` as `version` in the confirmed candidate response and do not infer from the candidate version.

```json
{
  "code": 0,
  "data": {
    "agent_id": "agent_01",
    "name": "产品助手",
    "description": "回答产品问题。",
    "model_name": "<MODEL_NAME>",
    "model_config_ref": "mc_01",
    "tool_names": [],
    "skill_names": [],
    "knowledge_base_names": [],
    "channel_bindings": [],
    "agent_md": "<AGENT_MARKDOWN>",
    "change_reason": "<CHANGE_REASON>"
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | integer | `0` on success. |
| `data.agent_id` | string | Agent ID, name and description. |
| `data.name` | string | Agent ID, name and description. |
| `data.description` | string | Agent ID, name and description. |
| `data.model_name` | string | Model name and model configuration reference. |
| `data.model_config_ref` | string | Model name and model configuration reference. |
| `data.tool_names` | string[] | Tool, skill, and knowledge base names in the candidate configuration. |
| `data.skill_names` | string[] | Tool, skill, and knowledge base names in the candidate configuration. |
| `data.knowledge_base_names` | string[] | Tool, skill, and knowledge base names in the candidate configuration. |
| `data.channel_bindings` | array | Channel binding configuration. |
| `data.agent_md` | string | Editable agent description content and reason for change. |
| `data.change_reason` | string | Editable agent description content and reason for change. |

`[]` after a type denotes an array. `[]` in a field path denotes each item in an array.

## Error response

```json
{
  "code": 3,
  "message": "<错误信息>"
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `2`（`INVALID_ARGUMENT`）
  - The path or `agent_workspace_id` is invalid, or the loaded version cannot be projected as an editable configuration.
  - Check version, workspace scope and package contents.
* - `401`
  - `6`（`UNAUTHENTICATED`）
  - Lack of valid identity credentials.
  - Check API Key.
* - `403`
  - `5`（`PERMISSION_DENIED`）
  - The current caller does not have permission to modify the agent.
  - Check workspace and agent authorizations.
* - `404`
  - `3`（`NOT_FOUND`）
  - Agent version does not exist.
  - Use `load_version` in the confirmation candidate response.
* - `500`
  - `1`（`INTERNAL`）
  - Current version of editable configuration projection fails.
  - Check package contents; contact support if it continues to fail.
* - `503`
  - `15`（`UNAVAILABLE`）
  - Smart package projection or licensing services are temporarily unavailable.
  - Try again later.
```

## Follow-up operations

When the candidate content needs to be modified [Regenerate agent candidate solutions](repropose-candidate.md).
