---
title: Nachdenken in Tool- und Multi-Turn-Workflows
url: https://platform.claude.com/docs/de/build-with-claude/thinking-tool-workflows
description: Gehe einen vollständigen Tool-Use-Roundtrip über zwei Turns durch, der Thinking-Blöcke korrekt bewahrt, und sieh dir an, wie verschachteltes Nachdenken den Ablauf verändert.
---

<Note>
  Um zu erfahren, wie „zero data retention“ (Null-Datenspeicherung), oder ZDR, auf diese Funktion angewendet wird, siehe [API und Datenspeicherung](https://platform.claude.com/docs/de/manage-claude/api-and-data-retention).
</Note>

Diese Seite führt durch einen vollständigen Tool-Use-Roundtrip über zwei Turns mit aktiviertem Nachdenken: Claude denkt, fordert einen Tool-Aufruf an, erhält das Ergebnis und schließt seine Antwort ab, wobei die „thinking blocks“ (Thinking-Blöcke) in jedem Schritt korrekt behandelt werden. Die vollständigen Regeln findest du auf der Seite [Nachdenken](https://platform.claude.com/docs/de/build-with-claude/thinking), in [Nachdenken mit Tool-Nutzung](https://platform.claude.com/docs/de/build-with-claude/thinking#thinking-with-tool-use) und [Thinking-Blöcke beibehalten](https://platform.claude.com/docs/de/build-with-claude/thinking#preserving-thinking-blocks); diese Seite zeigt diese Regeln angewendet in ausführbarem Code.

## Die Regeln, die dieser Walkthrough anwendet

Jeder Link führt zur vollständigen Formulierung auf der Seite Nachdenken:

* [Beschränke die Tool-Auswahl im manuellen Modus auf `auto` oder `none`](https://platform.claude.com/docs/de/build-with-claude/thinking#thinking-with-tool-use): `tool_choice`-Optionen, die eine Tool-Nutzung erzwingen, geben bei manuellem „extended thinking“ (erweitertem Nachdenken) (`thinking: {type: "enabled"}`) einen Fehler zurück. Adaptives Nachdenken unterstützt erzwungene Tool-Nutzung, außer bei Claude Opus 5.5, Claude Sonnet 5.5, Claude Fable 5.1 und Claude Mythos 5.1, die einen 400-Fehler zurückgeben. Wo erzwungene Tool-Nutzung akzeptiert wird, wird das Nachdenken übersprungen: Die Antwort beginnt mit dem Tool-Aufruf.
* [Behalte eine Thinking-Konfiguration pro Assistant-Turn bei](https://platform.claude.com/docs/de/build-with-claude/thinking#thinking-with-tool-use): Eine Tool-Use-Schleife ist ein einziger Assistant-Turn, ändere die Konfiguration also nur zwischen Turns.
* [Gib Thinking-Blöcke vollständig und unverändert zurück](https://platform.claude.com/docs/de/build-with-claude/thinking#preserving-thinking-blocks): Wenn du ein Tool-Ergebnis zurückgibst, müssen die Thinking-Blöcke aus der Assistant-Nachricht mit zurückkommen.
* [Gib die Assistant-Nachricht exakt so zurück, wie du sie erhalten hast](https://platform.claude.com/docs/de/build-with-claude/thinking#preserving-thinking-blocks): Das Neuaufbauen der Nachricht oder das Herausfiltern von `redacted_thinking`-Blöcken löst einen 400-Fehler aus.

Die Beispiele verwenden adaptives Nachdenken; auf Modellen, die nur erweitertes Nachdenken unterstützen, ersetze es durch `thinking: {type: "enabled", budget_tokens: N}`. Die Roundtrip-Regeln sind identisch.

## Einen Tool-Use-Roundtrip über zwei Turns durchgehen

Das Beispiel definiert ein `get_weather`-Tool, lässt Claude denken und einen Tool-Aufruf anfordern und gibt dann das Tool-Ergebnis zusammen mit dem Assistant-Turn zurück, der exakt so wiedergegeben wird, wie er empfangen wurde, einschließlich Thinking-Block.

<Steps>
  <Step title="Stelle die erste Anfrage mit einem verfügbaren Tool">
    Sende eine Anfrage mit aktiviertem adaptivem Nachdenken und definiertem Tool. Abgesehen vom `thinking`-Parameter ist dies eine standardmäßige Anfrage mit [Tool-Nutzung](https://platform.claude.com/docs/de/agents-and-tools/tool-use/overview):

    <CodeGroup>
      ```bash cURL
      curl https://api.anthropic.com/v1/messages \
        -H "anthropic-version: 2023-06-01" \
        -H "content-type: application/json" \
        -H "x-api-key: $ANTHROPIC_API_KEY" \
        -d '{
          "model": "claude-opus-5-5",
          "max_tokens": 16000,
          "thinking": {"type": "adaptive"},
          "tools": [{
            "name": "get_weather",
            "description": "Get current weather for a location",
            "input_schema": {
              "type": "object",
              "properties": {
                "location": {"type": "string", "description": "City name"}
              },
              "required": ["location"]
            }
          }],
          "messages": [{"role": "user", "content": "What is the weather in Paris?"}]
        }'
      ```

      ```bash CLI
      ant messages create --transform content <<'YAML'
      model: claude-opus-5-5
      max_tokens: 16000
      thinking:
        type: adaptive
      tools:
        - name: get_weather
          description: Get current weather for a location
          input_schema:
            type: object
            properties:
              location:
                type: string
                description: City name
            required:
              - location
      messages:
        - role: user
          content: "What's the weather in Paris?"
      YAML
      ```

      ```python Python

      client = anthropic.Anthropic()

      weather_tool = {
          "name": "get_weather",
          "description": "Get current weather for a location",
          "input_schema": {
              "type": "object",
              "properties": {"location": {"type": "string", "description": "City name"}},
              "required": ["location"],
          },
      }

      # Erste Anfrage – Claude antwortet mit Nachdenken und Tool-Anfrage
      response = client.messages.create(
          model="claude-opus-5-5",
          max_tokens=16000,
          thinking={"type": "adaptive"},
          tools=[weather_tool],
          messages=[{"role": "user", "content": "What's the weather in Paris?"}],
      )
      print(response)
      ```

      ```typescript TypeScript
      const client = new Anthropic();

      const weatherTool: Anthropic.Tool = {
        name: "get_weather",
        description: "Get current weather for a location",
        input_schema: {
          type: "object",
          properties: {
            location: { type: "string", description: "City name" }
          },
          required: ["location"]
        }
      };

      // Erste Anfrage – Claude antwortet mit Nachdenken und Tool-Anfrage
      const response = await client.messages.create({
        model: "claude-opus-5-5",
        max_tokens: 16000,
        thinking: {
          type: "adaptive"
        },
        tools: [weatherTool],
        messages: [{ role: "user", content: "What's the weather in Paris?" }]
      });
      console.log(response);
      ```

      ```csharp C#
      AnthropicClient client = new();

      var weatherTool = new ToolUnion(new Tool()
      {
          Name = "get_weather",
          Description = "Get current weather for a location",
          InputSchema = new InputSchema()
          {
              Properties = new Dictionary<string, JsonElement>
              {
                  ["location"] = JsonSerializer.SerializeToElement(new { type = "string", description = "City name" }),
              },
              Required = ["location"],
          },
      });

      var parameters = new MessageCreateParams
      {
          Model = Model.ClaudeOpus5_5,
          MaxTokens = 16000,
          Thinking = new ThinkingConfigAdaptive(),
          Tools = [weatherTool],
          Messages = [new() { Role = Role.User, Content = "What's the weather in Paris?" }]
      };

      var message = await client.Messages.Create(parameters);
      Console.WriteLine(message);
      ```

      ```go Go
      client := anthropic.NewClient()

      weatherTool := anthropic.ToolUnionParam{
      	OfTool: &anthropic.ToolParam{
      		Name:        "get_weather",
      		Description: anthropic.String("Get current weather for a location"),
      		InputSchema: anthropic.ToolInputSchemaParam{
      			Properties: map[string]any{
      				"location": map[string]any{
      					"type":        "string",
      					"description": "City name",
      				},
      			},
      			Required: []string{"location"},
      		},
      	},
      }

      response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
      	Model:     anthropic.ModelClaudeOpus5_5,
      	MaxTokens: 16000,
      	Thinking: anthropic.ThinkingConfigParamUnion{
      		OfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{},
      	},
      	Tools: []anthropic.ToolUnionParam{weatherTool},
      	Messages: []anthropic.MessageParam{
      		anthropic.NewUserMessage(anthropic.NewTextBlock("What's the weather in Paris?")),
      	},
      })
      if err != nil {
      	log.Fatal(err)
      }
      fmt.Println(response)
      ```

      ```java Java
      import com.anthropic.models.messages.ThinkingConfigAdaptive;
      // ...
          AnthropicClient client = AnthropicOkHttpClient.fromEnv();

          MessageCreateParams params = MessageCreateParams.builder()
              .model(Model.CLAUDE_OPUS_5_5)
              .maxTokens(16000L)
              .thinking(ThinkingConfigAdaptive.builder().build())
              .addTool(Tool.builder()
                  .name("get_weather")
                  .description("Get current weather for a location")
                  .inputSchema(Tool.InputSchema.builder()
                      .properties(JsonValue.from(Map.of(
                          "location", Map.of("type", "string", "description", "City name")
                      )))
                      .required(List.of("location"))
                      .build())
                  .build())
              .addUserMessage("What's the weather in Paris?")
              .build();

          Message response = client.messages().create(params);
          IO.println(response);
      ```

      ```php PHP
      $client = new Client();

      $weatherTool = [
          'name' => 'get_weather',
          'description' => 'Get current weather for a location',
          'input_schema' => [
              'type' => 'object',
              'properties' => [
                  'location' => ['type' => 'string', 'description' => 'City name']
              ],
              'required' => ['location']
          ]
      ];

      $message = $client->messages->create(
          maxTokens: 16000,
          messages: [
              ['role' => 'user', 'content' => "What's the weather in Paris?"]
          ],
          model: 'claude-opus-5-5',
          thinking: ['type' => 'adaptive'],
          tools: [$weatherTool],
      );
      echo $message;
      ```

      ```ruby Ruby
      client = Anthropic::Client.new

      weather_tool = {
        name: "get_weather",
        description: "Get current weather for a location",
        input_schema: {
          type: "object",
          properties: {
            location: { type: "string", description: "City name" }
          },
          required: ["location"]
        }
      }

      message = client.messages.create(
        model: "claude-opus-5-5",
        max_tokens: 16000,
        thinking: {
          type: "adaptive"
        },
        tools: [weather_tool],
        messages: [
          { role: "user", content: "What's the weather in Paris?" }
        ]
      )
      puts message
      ```
    </CodeGroup>
  </Step>

  <Step title="Erfasse das Content-Array, um es zurückzugeben">
    Bei einem Durchlauf, in dem Claude sich zum Nachdenken entschieden hat, solltest du `thinking`- und `tool_use`-Blöcke im Antwortinhalt sehen (bei einfacheren Anfragen kann der adaptive Modus den Thinking-Block überspringen). Eine Notiz, die Claude vor dem Tool-Aufruf schreibt, kommt als `text`-Block zurück oder, bei Modellen, die [Fortschrittsmeldungen](https://platform.claude.com/docs/de/build-with-claude/thinking#progress-updates) schreiben, als weiterer `thinking`-Block. Lass dieses Content-Array unverändert: Der nächste Schritt sendet es wortwörtlich zurück.

    <Note>
      Um Thinking-Text wie in dieser Ausgabe zu sehen, füge der Anfrage `display: "summarized"` hinzu. Bei Modellen, bei denen die Anzeige standardmäßig auf „omitted“ steht, einschließlich Claude Opus 5.5, kommt das `thinking`-Feld andernfalls als leerer String zurück, wobei nur die `signature` befüllt ist. In beiden Fällen sendest du das Content-Array unverändert zurück; siehe [Anzeige des Nachdenkens steuern](https://platform.claude.com/docs/de/build-with-claude/thinking#controlling-thinking-display).
    </Note>

    ```json Output
    {
      "content": [
        {
          "type": "thinking",
          "thinking": "The user wants to know the current weather in Paris. I have access to a function `get_weather`...",
          "signature": "BDaL4VrbR2Oj0hO4XpJxT28J5T...."
        },
        {
          "type": "tool_use",
          "id": "toolu_01CswdEQBMshySk6Y9DFKrfq",
          "name": "get_weather",
          "input": {
            "location": "Paris"
          }
        }
      ]
    }
    ```
  </Step>

  <Step title="Gib das Tool-Ergebnis zurück und wiederhole den Assistant-Turn wortwörtlich">
    Führe das Tool auf deiner Seite aus und sende dann eine zweite Anfrage, die zwei Nachrichten an die Konversation anhängt. Die erste ist der Assistant-Inhalt, exakt so zurückgegeben, wie er empfangen wurde, sodass der Thinking-Block neben dem `tool_use`-Block unverändert bleibt. Die zweite ist eine User-Nachricht, die das `tool_result` enthält.

    Jedes Beispiel ist ein eigenständiges Skript: Es wiederholt die erste Anfrage und sendet dann sofort die Folgeanfrage mit der gerade erhaltenen Antwort.

    <CodeGroup exclude="shell:cURL">
      <CodeGroupItem language="cURL">
        Dieser Workflow erfordert mehr Logik als ein einzelner Shell-Befehl. Verwende das Claude SDK, um ihn auszuführen.
      </CodeGroupItem>

      ```bash CLI
      # Erster Turn: Schreibe das Content-Array des Assistenten (Thinking- und tool_use-
      # Blöcke, Signaturen unverändert) in eine Datei. Modellgenerierten Text über eine
      # Datei zu leiten, hält ihn später aus Positionen mit Shell-Expansion heraus.
      ant messages create --transform content --format jsonl \
        > assistant_content.json <<'YAML'
      model: claude-opus-5-5
      max_tokens: 16000
      thinking:
        type: adaptive
      tools:
        - name: get_weather
          description: Get current weather for a location
          input_schema:
            type: object
            properties:
              location:
                type: string
                description: City name
            required: [location]
      messages:
        - role: user
          content: What's the weather in Paris?
      YAML

      # Zweiter Turn: jq füllt die beiden null-Platzhalter aus der gespeicherten Datei,
      # sodass die Blöcke wortgetreu als Assistenten-Nachricht zurückgehen. Der Thinking-Block
      # MUSS den tool_use-Block begleiten. Der in Anführungszeichen gesetzte Delimiter verhindert,
      # dass die Shell irgendetwas im Body expandiert.
      jq --slurpfile blocks assistant_content.json '
        .messages[1].content = $blocks[0] |
        .messages[2].content[0].tool_use_id =
          ($blocks[0][] | select(.type == "tool_use") | .id)
      ' <<'JSON' | ant messages create
      {
        "model": "claude-opus-5-5",
        "max_tokens": 16000,
        "thinking": {"type": "adaptive"},
        "tools": [{
          "name": "get_weather",
          "description": "Get current weather for a location",
          "input_schema": {
            "type": "object",
            "properties": {
              "location": {"type": "string", "description": "City name"}
            },
            "required": ["location"]
          }
        }],
        "messages": [
          {"role": "user", "content": "What's the weather in Paris?"},
          {"role": "assistant", "content": null},
          {"role": "user", "content": [{
            "type": "tool_result",
            "tool_use_id": null,
            "content": "Current temperature: 88°F"
          }]}
        ]
      }
      JSON
      ```

      ```python Python

      client = anthropic.Anthropic()
      weather_tool = {
          "name": "get_weather",
          "description": "Get current weather for a location",
          "input_schema": {
              "type": "object",
              "properties": {"location": {"type": "string", "description": "City name"}},
              "required": ["location"],
          },
      }
      response = client.messages.create(
          model="claude-opus-5-5",
          max_tokens=16000,
          thinking={"type": "adaptive"},
          tools=[weather_tool],
          messages=[{"role": "user", "content": "What's the weather in Paris?"}],
      )
      # Extrahiere den tool_use-Block, um seine ID für das tool_result zu erhalten
      tool_use_block = next(block for block in response.content if block.type == "tool_use")

      # Rufe deine eigentliche Wetter-API auf; hier würde dein tatsächlicher API-Aufruf stehen
      # Nehmen wir an, das ist die Antwort, die wir zurückbekommen
      weather_data = {"temperature": 88}

      # Zweite Anfrage – Füge den Assistant-Turn und das tool_result hinzu
      continuation = client.messages.create(
          model="claude-opus-5-5",
          max_tokens=16000,
          thinking={"type": "adaptive"},
          tools=[weather_tool],
          messages=[
              {"role": "user", "content": "What's the weather in Paris?"},
              # Gib den Assistant-Inhalt exakt so zurück, wie er empfangen wurde. Wenn ein Thinking-
              # Block vorhanden ist, muss er den tool_use-Block begleiten.
              {"role": "assistant", "content": response.content},
              {
                  "role": "user",
                  "content": [
                      {
                          "type": "tool_result",
                          "tool_use_id": tool_use_block.id,
                          "content": f"Current temperature: {weather_data['temperature']}°F",
                      }
                  ],
              },
          ],
      )
      print(continuation)
      ```

      ```typescript TypeScript
      const client = new Anthropic();

      const weatherTool: Anthropic.Tool = {
        name: "get_weather",
        description: "Get current weather for a location",
        input_schema: {
          type: "object",
          properties: {
            location: { type: "string", description: "City name" }
          },
          required: ["location"]
        }
      };

      const response = await client.messages.create({
        model: "claude-opus-5-5",
        max_tokens: 16000,
        thinking: {
          type: "adaptive"
        },
        tools: [weatherTool],
        messages: [{ role: "user", content: "What's the weather in Paris?" }]
      });

      // Extrahiere den tool_use-Block, um seine ID für das tool_result zu erhalten
      const toolUseBlock = response.content.find(
        (block): block is Anthropic.ToolUseBlock => block.type === "tool_use"
      );

      // Rufe deine eigentliche Wetter-API auf, hier würde dein tatsächlicher API-Aufruf stehen
      // Nehmen wir an, das ist die Antwort, die wir zurückbekommen
      const weatherData = { temperature: 88 };

      if (toolUseBlock) {
        // Zweite Anfrage – Füge den Assistant-Turn und das tool_result hinzu
        const continuation = await client.messages.create({
          model: "claude-opus-5-5",
          max_tokens: 16000,
          thinking: {
            type: "adaptive"
          },
          tools: [weatherTool],
          messages: [
            { role: "user", content: "What's the weather in Paris?" },
            // Gib den Assistant-Inhalt exakt so zurück, wie er empfangen wurde. Wenn ein Thinking-
            // Block vorhanden ist, muss er den tool_use-Block begleiten.
            { role: "assistant", content: response.content },
            {
              role: "user",
              content: [
                {
                  type: "tool_result" as const,
                  tool_use_id: toolUseBlock.id,
                  content: `Current temperature: ${weatherData.temperature}°F`
                }
              ]
            }
          ]
        });
        console.log(continuation);
      }
      ```

      ```csharp C#
      AnthropicClient client = new();

      var weatherTool = new ToolUnion(new Tool()
      {
          Name = "get_weather",
          Description = "Get current weather for a location",
          InputSchema = new InputSchema()
          {
              Properties = new Dictionary<string, JsonElement>
              {
                  ["location"] = JsonSerializer.SerializeToElement(new { type = "string", description = "City name" }),
              },
              Required = ["location"],
          },
      });

      var parameters = new MessageCreateParams
      {
          Model = Model.ClaudeOpus5_5,
          MaxTokens = 16000,
          Thinking = new ThinkingConfigAdaptive(),
          Tools = [weatherTool],
          Messages = [
              new() { Role = Role.User, Content = "What's the weather in Paris?" }
          ]
      };

      var response = await client.Messages.Create(parameters);

      // Extrahiere den tool_use-Block, um seine ID für das Tool-Ergebnis zu erhalten
      ToolUseBlock? toolUseBlock = null;
      foreach (var block in response.Content)
      {
          if (block.TryPickToolUse(out var toolUse))
          {
              toolUseBlock = toolUse;
              break;
          }
      }

      var weatherData = new { temperature = 88 };

      // Erstelle die Fortsetzung mit dem Tool-Ergebnis
      var continuationParams = new MessageCreateParams
      {
          Model = Model.ClaudeOpus5_5,
          MaxTokens = 16000,
          Thinking = new ThinkingConfigAdaptive(),
          Tools = [weatherTool],
          Messages = [
              new() { Role = Role.User, Content = "What's the weather in Paris?" },
              // response.Content enthält die Thinking-Blöcke; sie zurückzugeben ist erforderlich
              new() { Role = Role.Assistant, Content = response.Content.Select(block => new ContentBlockParam(block.Json)).ToList() },
              new() { Role = Role.User, Content = new MessageParamContent(new List<ContentBlockParam>
              {
                  new ContentBlockParam(new ToolResultBlockParam()
                  {
                      ToolUseID = toolUseBlock?.ID ?? "",
                      Content = $"Current temperature: {weatherData.temperature}°F"
                  })
              })}
          ]
      };

      var continuation = await client.Messages.Create(continuationParams);
      Console.WriteLine(continuation);
      ```

      ```go Go
      client := anthropic.NewClient()

      weatherTool := anthropic.ToolUnionParam{
      	OfTool: &anthropic.ToolParam{
      		Name:        "get_weather",
      		Description: anthropic.String("Get current weather for a location"),
      		InputSchema: anthropic.ToolInputSchemaParam{
      			Properties: map[string]any{
      				"location": map[string]any{
      					"type":        "string",
      					"description": "City name",
      				},
      			},
      			Required: []string{"location"},
      		},
      	},
      }

      response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
      	Model:     anthropic.ModelClaudeOpus5_5,
      	MaxTokens: 16000,
      	Thinking: anthropic.ThinkingConfigParamUnion{
      		OfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{},
      	},
      	Tools: []anthropic.ToolUnionParam{weatherTool},
      	Messages: []anthropic.MessageParam{
      		anthropic.NewUserMessage(anthropic.NewTextBlock("What's the weather in Paris?")),
      	},
      })
      if err != nil {
      	log.Fatal(err)
      }

      var toolUseBlock anthropic.ToolUseBlock
      for _, block := range response.Content {
      	if v, ok := block.AsAny().(anthropic.ToolUseBlock); ok {
      		toolUseBlock = v
      		break
      	}
      }

      weatherData := map[string]int{"temperature": 88}

      continuation, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
      	Model:     anthropic.ModelClaudeOpus5_5,
      	MaxTokens: 16000,
      	Thinking: anthropic.ThinkingConfigParamUnion{
      		OfAdaptive: &anthropic.ThinkingConfigAdaptiveParam{},
      	},
      	Tools: []anthropic.ToolUnionParam{weatherTool},
      	Messages: []anthropic.MessageParam{
      		anthropic.NewUserMessage(anthropic.NewTextBlock("What's the weather in Paris?")),
      		response.ToParam(),
      		anthropic.NewUserMessage(
      			anthropic.NewToolResultBlock(toolUseBlock.ID, fmt.Sprintf("Current temperature: %d°F", weatherData["temperature"]), false),
      		),
      	},
      })
      if err != nil {
      	log.Fatal(err)
      }

      fmt.Println(continuation)
      ```

      ```java Java
      import com.anthropic.models.messages.ThinkingConfigAdaptive;
      // ...

      void main() {
          AnthropicClient client = AnthropicOkHttpClient.fromEnv();

          Tool weatherTool = Tool.builder()
              .name("get_weather")
              .description("Get current weather for a location")
              .inputSchema(Tool.InputSchema.builder()
                  .properties(JsonValue.from(Map.of(
                      "location", Map.of("type", "string", "description", "City name")
                  )))
                  .required(List.of("location"))
                  .build())
              .build();

          MessageCreateParams initialParams = MessageCreateParams.builder()
              .model(Model.CLAUDE_OPUS_5_5)
              .maxTokens(16000L)
              .thinking(ThinkingConfigAdaptive.builder().build())
              .addTool(weatherTool)
              .addUserMessage("What's the weather in Paris?")
              .build();

          Message response = client.messages().create(initialParams);

          ToolUseBlock toolUseBlock = null;
          for (var block : response.content()) {
              if (block.toolUse().isPresent()) {
                  toolUseBlock = block.toolUse().get();
                  break;
              }
          }

          int temperature = 88;

          // Zweite Anfrage: den Assistant-Turn unverändert zurückgeben, dann das Tool-Ergebnis
          MessageCreateParams continuationParams = MessageCreateParams.builder()
              .model(Model.CLAUDE_OPUS_5_5)
              .maxTokens(16000L)
              .thinking(ThinkingConfigAdaptive.builder().build())
              .addTool(weatherTool)
              .addUserMessage("What's the weather in Paris?")
              .addMessage(response)
              .addUserMessageOfBlockParams(List.of(
                  ContentBlockParam.ofToolResult(
                      ToolResultBlockParam.builder()
                          .toolUseId(toolUseBlock.id())
                          .content("Current temperature: " + temperature + "°F")
                          .build()
                  )
              ))
              .build();

          Message continuation = client.messages().create(continuationParams);
          IO.println(continuation);
      }
      ```

      ```php PHP
      $client = new Client();

      $weatherTool = [
          'name' => 'get_weather',
          'description' => 'Get current weather for a location',
          'input_schema' => [
              'type' => 'object',
              'properties' => [
                  'location' => [
                      'type' => 'string',
                      'description' => 'City name'
                  ]
              ],
              'required' => ['location']
          ]
      ];

      $response = $client->messages->create(
          maxTokens: 16000,
          messages: [
              ['role' => 'user', 'content' => "What's the weather in Paris?"]
          ],
          model: 'claude-opus-5-5',
          thinking: ['type' => 'adaptive'],
          tools: [$weatherTool],
      );

      $toolUseBlock = null;
      foreach ($response->content as $block) {
          if ($block->type === 'tool_use') {
              $toolUseBlock = $block;
              break;
          }
      }

      $weatherData = ['temperature' => 88];

      $continuation = $client->messages->create(
          maxTokens: 16000,
          messages: [
              ['role' => 'user', 'content' => "What's the weather in Paris?"],
              ['role' => 'assistant', 'content' => $response->content],
              ['role' => 'user', 'content' => [
                  [
                      'type' => 'tool_result',
                      'tool_use_id' => $toolUseBlock->id,
                      'content' => "Current temperature: {$weatherData['temperature']}°F"
                  ]
              ]]
          ],
          model: 'claude-opus-5-5',
          thinking: ['type' => 'adaptive'],
          tools: [$weatherTool],
      );

      echo $continuation;
      ```

      ```ruby Ruby
      client = Anthropic::Client.new

      weather_tool = {
        name: "get_weather",
        description: "Get current weather for a location",
        input_schema: {
          type: "object",
          properties: {
            location: { type: "string", description: "City name" }
          },
          required: ["location"]
        }
      }

      response = client.messages.create(
        model: "claude-opus-5-5",
        max_tokens: 16000,
        thinking: {
          type: "adaptive"
        },
        tools: [weather_tool],
        messages: [
          { role: "user", content: "What's the weather in Paris?" }
        ]
      )

      tool_use_block = response.content.find { |block| block.type == :tool_use }

      raise "No tool_use block found" unless tool_use_block

      weather_data = { temperature: 88 }

      continuation = client.messages.create(
        model: "claude-opus-5-5",
        max_tokens: 16000,
        thinking: {
          type: "adaptive"
        },
        tools: [weather_tool],
        messages: [
          { role: "user", content: "What's the weather in Paris?" },
          { role: "assistant", content: response.content },
          { role: "user", content: [
            {
              type: "tool_result",
              tool_use_id: tool_use_block.id,
              content: "Current temperature: #{weather_data[:temperature]}°F"
            }
          ] }
        ]
      )

      puts continuation
      ```
    </CodeGroup>
  </Step>

  <Step title="Lies die endgültige Antwort">
    Du solltest sehen, wie Claude den Turn mit Text abschließt. Da [„interleaved thinking“ (verschachteltes Nachdenken)](https://platform.claude.com/docs/de/build-with-claude/thinking#interleaved-thinking) im adaptiven Modus automatisch erfolgt, kann die Fortsetzung auch mit einem neuen Thinking-Block vor dem endgültigen Text beginnen:

    ```json Output
    {
      "content": [
        {
          "type": "text",
          "text": "Currently in Paris, the temperature is 88°F (31°C)"
        }
      ]
    }
    ```
  </Step>
</Steps>

## Wie verschachteltes Nachdenken den Ablauf verändert

Verschachteltes Nachdenken ermöglicht es Claude, zwischen Tool-Aufrufen zu denken und über jedes Tool-Ergebnis nachzudenken, bevor es darauf reagiert. Das Konzept und die Verfügbarkeit pro Modell werden in [Verschachteltes Nachdenken](https://platform.claude.com/docs/de/build-with-claude/thinking#interleaved-thinking) auf der Seite Nachdenken behandelt; die Verschachtelung ändert, wo Thinking-Blöcke erscheinen, nicht, ob Tool-Aufrufe verkettet werden können. Der folgende Vergleich zeigt, was verschachteltes Nachdenken in einem Workflow mit zwei Tools verändert:

<AccordionGroup>
  <Accordion title="Tool-Nutzung ohne verschachteltes Nachdenken">
    Ohne verschachteltes Nachdenken denkt Claude einmal zu Beginn des Assistant-Turns. Nachfolgende Antworten nach Tool-Ergebnissen werden ohne neue Thinking-Blöcke fortgesetzt.

    ```text
    User: "What's the total revenue if we sold 150 units at $50 each,
           and how does this compare to our average monthly revenue?"

    Response 1: [thinking] "I need to calculate 150 * $50, then check the database..."
                [tool_use: calculator] { "expression": "150 * 50" }
      ↓ tool result: "7500"

    Response 2: [tool_use: database_query] { "query": "SELECT AVG(revenue)..." }
                ↑ no thinking block
      ↓ tool result: "5200"

    Response 3: [text] "The total revenue is $7,500, which is 44% above your
                average monthly revenue of $5,200."
                ↑ no thinking block
    ```
  </Accordion>

  <Accordion title="Tool-Nutzung mit verschachteltem Nachdenken">
    Mit aktiviertem verschachteltem Nachdenken kann Claude nach dem Erhalt jedes Tool-Ergebnisses denken, was es ihm ermöglicht, über Zwischenergebnisse nachzudenken, bevor es fortfährt.

    ```text
    User: "What's the total revenue if we sold 150 units at $50 each,
           and how does this compare to our average monthly revenue?"

    Response 1: [thinking] "I need to calculate 150 * $50 first..."
                [tool_use: calculator] { "expression": "150 * 50" }
      ↓ tool result: "7500"

    Response 2: [thinking] "Got $7,500. Now I should query the database to compare..."
                [tool_use: database_query] { "query": "SELECT AVG(revenue)..." }
                ↑ thinking after receiving calculator result
      ↓ tool result: "5200"

    Response 3: [thinking] "$7,500 vs $5,200 average - that's a 44% increase..."
                [text] "The total revenue is $7,500, which is 44% above your
                average monthly revenue of $5,200."
                ↑ thinking before final answer
    ```
  </Accordion>
</AccordionGroup>

## Nächste Schritte

<CardGroup cols={3}>
  <Card title="Nachdenken" icon="brain" href="https://platform.claude.com/docs/de/build-with-claude/thinking">
    Der Überblick: Nachdenken aktivieren, Thinking-Ausgabe lesen und die vollständigen Regeln für Tool-Nutzung, Caching und Streaming durchgehen.
  </Card>

  <Card title="Nachdenken steuern" icon="compass" href="https://platform.claude.com/docs/de/build-with-claude/thinking-steering-and-cost">
    Steuere mit Effort-Stufen und Prompt-basierter Anleitung, wie oft und wie tief Claude denkt.
  </Card>

  <Card title="Erweitertes Nachdenken" icon="clock" href="https://platform.claude.com/docs/de/build-with-claude/extended-thinking">
    Manuelle Thinking-Budgets auf älteren Modellen: `budget_tokens`-Mechanik und Migration zu adaptivem Nachdenken.
  </Card>
</CardGroup>
