sequentialthinking

package module
v0.0.0-...-20b2a55 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 2

README

Sequential Thinking Tool

Sequential Thinking Tool is a tool for dynamic and reflective problem-solving through a structured thinking process. Inspired by @modelcontextprotocol /sequentialthinking, it guides LLM through a series of questions to help them think through problems step-by-step.

Features

  • Guided step-by-step thinking process.
  • Dynamic questioning and reflection.
  • Enhances problem-solving abilities.

Usage

The Sequential Thinking tool is designed for:

  • Breaking down complex problems into steps
  • Planning and design with room for revision
  • Analysis that might need course correction
  • Problems where the full scope might not be clear initially
  • Tasks that need to maintain context over multiple steps
  • Situations where irrelevant information needs to be filtered out

Install

go get github.com/cloudwego/eino-ext/components/tool/sequentialthinking@latest

Quick Start

package main

import (
	"context"
	"fmt"
	
	"github.com/bytedance/sonic"
	
	"github.com/cloudwego/eino-ext/components/tool/sequentialthinking"
)

func main() {
	ctx := context.Background()
	
	// Instantiate the tool
	tool, err := sequentialthinking.NewTool()
	if err != nil {
		panic(err)
	}
	
	args := &sequentialthinking.ThoughtRequest{
		Thought:           "This is a test thought",
		ThoughtNumber:     1,
		TotalThoughts:     3,
		NextThoughtNeeded: true,
	}
	
	argsStr, _ := sonic.Marshal(args)
	
	// Use the tool
	// (This is just a placeholder; actual usage will depend on the tool's functionality)
	result, err := tool.InvokableRun(ctx, string(argsStr))
	if err != nil {
		panic(err)
	}
	
	// Process the result
	// (This is just a placeholder; actual processing will depend on the tool's output)
	fmt.Println(result)
}

Examples

See the examples directory for complete usage examples.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTool

func NewTool() (tool.InvokableTool, error)

NewTool creates a new sequential thinking tool instance. Returns:

  • tool: An invokable tool interface
  • err: An error if tool creation fails

Types

type ThoughtRequest

type ThoughtRequest struct {
	Thought           string `json:"thought" jsonschema:"required" jsonschema_description:"Your current thinking step"`
	ThoughtNumber     int    `json:"thought_number" jsonschema:"required" jsonschema_description:"Current thought number"`
	TotalThoughts     int    `json:"total_thoughts" jsonschema:"required" jsonschema_description:"Estimated total thoughts needed"`
	IsRevision        bool   `json:"is_revision,omitempty" jsonschema_description:"Whether this revises previous thinking"`
	RevisesThought    int    `json:"revises_thought,omitempty" jsonschema_description:"Which thought is being reconsidered"`
	BranchFromThought int    `json:"branch_from_thought,omitempty" jsonschema_description:"Branching point thought number"`
	BranchID          string `json:"branch_id,omitempty" jsonschema_description:"Branch identifier"`
	NeedsMoreThoughts bool   `json:"needs_more_thoughts,omitempty" jsonschema_description:"If more thoughts are needed"`
	NextThoughtNeeded bool   `json:"next_thought_needed" jsonschema:"required" jsonschema_description:"Whether another thought step is needed"`
}

ThoughtRequest represents a single step in the sequential thinking process. It captures the thought content and metadata about the thinking process.

type ThoughtResult

type ThoughtResult struct {
	Content              string   `json:"content" jsonschema:"required" jsonschema_description:"Your current thinking step"`
	ThoughtNumber        int      `json:"thought_number" jsonschema:"required" jsonschema_description:"Current thought number"`
	TotalThoughts        int      `json:"total_thoughts" jsonschema:"required" jsonschema_description:"Estimated total thoughts needed"`
	NextThoughtNeeded    bool     `json:"next_thought_needed" jsonschema:"required" jsonschema_description:"Which thought is needed"`
	Branches             []string `json:"branches" jsonschema_description:"Branch identifier"`
	ThoughtHistoryLength int      `json:"thought_history_length" jsonschema_description:"Length of thoughts history needed"`
}

ThoughtResult represents the formatted output of processing a thought. It contains the content to display and metadata about the thinking state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL