Skip to content

Add support for Command A Reasoning#174

Open
Steven Connors (steven-connors-cohere) wants to merge 2 commits intolangchain-ai:mainfrom
steven-connors-cohere:command-a-reasoning-support
Open

Add support for Command A Reasoning#174
Steven Connors (steven-connors-cohere) wants to merge 2 commits intolangchain-ai:mainfrom
steven-connors-cohere:command-a-reasoning-support

Conversation

@steven-connors-cohere
Copy link
Contributor

@steven-connors-cohere Steven Connors (steven-connors-cohere) commented Mar 4, 2026

This PR introduces support for Command A Reasoning into the langchain-cohere library.

This PR should resolve this issue: #164

Testing

  • Verified by hitting the Cohere API with the new branch to confirm reasoning traces are parsed appropriately with ChatCohere.
  • Newly created unit & integration tests

Results

output.zip
Above file containing the AIMessage outputs from the different models + libs.

ChatCohere with Command A Reasoning

{
  "type": "AIMessageChunk",
  "content": [
    {
      "type": "reasoning",
      "index": 0,
      "summary": [
        {
          "text": "First, I recognize that the problem is asking for the product of 7 and 8.\n\nI recall the multiplication table for the number 7.\n\nFrom memory, 7 multiplied by 8 equals 56.",
          "type": "summary_text",
          "index": 0
        }
      ]
    },
    {
      "type": "text",
      "index": 1,
      "text": "To find the product of \\(7\\) and \\(8\\), follow these easy steps:\n\n1. **Understand the Problem:**\n   \n   We need to calculate \\(7 \\times 8\\).\n\n2. **Recall the Multiplication Table:**\n   \n   Remember the multiplication table for the number 7:\n   \n   \\[\n   \\begin{align*}\n   7 \\times 1 &= 7 \\\\\n   7 \\times 2 &= 14 \\\\\n   7 \\times 3 &= 21 \\\\\n   7 \\times 4 &= 28 \\\\\n   7 \\times 5 &= 35 \\\\\n   7 \\times 6 &= 42 \\\\\n   7 \\times 7 &= 49 \\\\\n   7 \\times 8 &= 56 \\\\\n   \\end{align*}\n   \\]\n\n3. **Identify the Required Multiplication:**\n   \n   From the table above, \\(7 \\times 8 = 56\\).\n\n4. **Final Answer:**\n   \n   \\[\n   \\boxed{56}\n   \\]"
    }
  ],
  "additional_kwargs": {
    "finish_reason": "COMPLETE",
    "token_count": {
      "total_tokens": 275.0,
      "input_tokens": 15.0,
      "output_tokens": 260.0
    }
  }
}

ChatOpenAI with GPT-5

{
  "type": "AIMessageChunk",
  "content": [
    {
      "id": "rs_0cd32f094434d901006989a3dfd76c8196ad565b868114fef6",
      "summary": [
        {
          "index": 0,
          "type": "summary_text",
          "text": "**Explaining multiplication methods**\n\nI need to consider how to properly explain that 7 times 8 equals 56. I could show it as repeated addition, like 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7, or simply as 8 times 7. A clearer method might be presenting it in a step-by-step way, like saying 8 times 7 can be broken down into (8 times 5) plus (8 times 2), which equals 40 plus 16, giving us 56."
        },
        {
          "index": 1,
          "type": "summary_text",
          "text": "**Calculating multiplication steps**\n\nI need to provide a short calculation to show that 7 times 8 equals 56. I could express it as 7 added together eight times, or break it down as 8 times 7 equals (8 times 5) plus (8 times 2), which gives 40 plus 16, resulting in 56. To keep it concise and non-deliberative, I should say: \"Compute 7 times 8 directly, or use repeated addition.\" The repeated addition demonstrates the arithmetic clearly, which is acceptable as a straightforward explanation."
        },
        {
          "index": 2,
          "type": "summary_text",
          "text": "**Presenting multiplication clearly**\n\nI need to show the steps for calculating 7 times 8 without overthinking it. I should focus on providing a straightforward answer and a short calculation. The answer is 56. \n\nFor a brief explanation, I could say: 7 times 8 can be viewed as adding 7 together eight times, which looks like 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 = 56. I wanted to mention the distributive property, but it\u2019s really just straightforward arithmetic, so keeping it simple is best."
        },
        {
          "index": 3,
          "type": "summary_text",
          "text": "**Explaining multiplication clearly**\n\nI can streamline the explanation for 8 times 7 to keep it concise and straightforward. I should break down the steps without getting too introspective. \n\nFor example, I can show it like this: Step 1: Break 8 into 5 plus 2; then apply the distributive property, so 8 times (5 plus 2) becomes 8 times 5 plus 8 times 2, which equals 40 plus 16. Step 2: Finally, sum 40 and 16 to get 56. This method is clear and avoids excessive internal reasoning while providing the necessary steps."
        },
        {
          "index": 4,
          "type": "summary_text",
          "text": "**Providing multiplication methods**\n\nLet's keep this concise! The answer to 7 times 8 is 56. \n\nFor a quick breakdown, I can show it in two ways. First, as repeated addition: 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 = 56. Alternatively, I can use the distributive property: 7 \u00d7 8 equals 8 \u00d7 (5 + 2), which simplifies to 8 \u00d7 5 plus 8 \u00d7 2, giving us 40 + 16 = 56. If the user prefers a different method, I can certainly provide that too!"
        }
      ],
      "type": "reasoning",
      "index": 0
    },
    {
      "type": "text",
      "text": "Answer: 56\n\nBrief explanation (non-deliberative):\n- Method 1 (repeated addition): 7 + 7 + 7 + 7 + 7 + 7 + 7 + 7 = 56\n- Method 2 (distributive): 7 \u00d7 8 = 8 \u00d7 (5 + 2) = 8\u00d75 + 8\u00d72 = 40 + 16 = 56\n\nIf you\u2019d like a different approach, I can show it too.",
      "index": 1,
      "id": "msg_0cd32f094434d901006989a3ee48048196b9b66f06ac554997"
    }
  ],
  "additional_kwargs": {},
  "usage_metadata": {
    "input_tokens": 21,
    "output_tokens": 1696,
    "total_tokens": 1717,
    "input_token_details": {
      "cache_read": 0
    },
    "output_token_details": {
      "reasoning": 1536
    }
  }
}

@steven-connors-cohere Steven Connors (steven-connors-cohere) changed the title Add support for Command A Reasoning (#33) Add support for Command A Reasoning Mar 4, 2026
@steven-connors-cohere
Copy link
Contributor Author

Hi John Kennedy (@jkennedyvz) , ccurme (@ccurme) !

I'm wondering if its appropriate to tag either one of you to get the workflow to be approved for this PR?
Let me know if you don't have write perms to trigger the Workflow and I can work on hunting them down.
Thanks!

Screenshot 2026-03-04 at 15 45 17

@steven-connors-cohere
Copy link
Contributor Author

Steven Connors (steven-connors-cohere) commented Mar 6, 2026

Hi John Kennedy (@jkennedyvz) , ccurme (@ccurme) -- pinging again to get the workflow approved.

Q: any chance we can remove this approval? Definitely don't want to keep bothering y'all for something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant