---
url: >-
  https://adk.nht.io/api/@nhtio/adk/spooled_artifact/functions/resolveArtifactById.md
---

# Function: resolveArtifactById()

```ts
function resolveArtifactById(
  ctx: {
    turnRetrievables: Iterable<{
      content: unknown;
      id: string;
      inline: boolean;
    }>;
    turnToolCalls: Iterable<{
      fromArtifactTool?: boolean;
      id: string;
      results: unknown;
    }>;
  },
  id: string,
  requires: SpooledArtifactConstructor,
):
  | {
      artifact: SpooledArtifact;
      source: "toolCall" | "retrievable";
    }
  | undefined;
```

Defined in: [src/lib/classes/spooled\_artifact.ts:113](https://github.com/NHTIO/ADK/blob/v1.20260907.0/src/src/lib/classes/spooled_artifact.ts#L113)

Resolve an artifact by ID from the current turn's tool calls or retrievables, with type narrowing.

## Parameters

| Parameter              | Type                                                                                                                                                                                                                  | Description                                                                            |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| `ctx`                  | { `turnRetrievables`: `Iterable`<{ `content`: `unknown`; `id`: `string`; `inline`: `boolean`; }>; `turnToolCalls`: `Iterable`<{ `fromArtifactTool?`: `boolean`; `id`: `string`; `results`: `unknown`; }>; } | The dispatch context containing tool calls and retrievables.                           |
| `ctx.turnRetrievables` | `Iterable`<{ `content`: `unknown`; `id`: `string`; `inline`: `boolean`; }>                                                                                                                                        | -                                                                                      |
| `ctx.turnToolCalls`    | `Iterable`<{ `fromArtifactTool?`: `boolean`; `id`: `string`; `results`: `unknown`; }>                                                                                                                             | -                                                                                      |
| `id`                   | `string`                                                                                                                                                                                                              | The artifact ID to resolve.                                                            |
| `requires`             | [`SpooledArtifactConstructor`](../../forge/type-aliases/SpooledArtifactConstructor.md)                                                                                                                                | The artifact class constructor to narrow by; only artifacts of this type are returned. |

## Returns

| {
`artifact`: [`SpooledArtifact`](../classes/SpooledArtifact.md);
`source`: `"toolCall"` | `"retrievable"`;
}
| `undefined`

The resolved artifact and its source (tool call or retrievable), or undefined if not found.
