• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kshard / thinker / 14181687602

31 Mar 2025 09:19PM UTC coverage: 61.033% (-4.9%) from 65.921%
14181687602

Pull #11

github

fogfish
add unit test for memory purge
Pull Request #11: enhance framework with composable primitives

7 of 81 new or added lines in 9 files covered. (8.64%)

390 of 639 relevant lines covered (61.03%)

0.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.45
/reasoner/command.go
1
//
2
// Copyright (C) 2025 Dmitry Kolesnikov
3
//
4
// This file may be modified and distributed under the terms
5
// of the MIT license.  See the LICENSE file for details.
6
// https://github.com/kshard/thinker
7
//
8

9
package reasoner
10

11
import (
12
        "fmt"
13

14
        "github.com/kshard/chatter"
15
        "github.com/kshard/thinker"
16
        "github.com/kshard/thinker/command"
17
)
18

19
// State of Command reasoner
20
type StateCmd = thinker.State[thinker.CmdOut]
21

22
// The cmd (command) reasoner set the goal for agent to execute a single command.
23
// It returns right after the command return results.
24
type Cmd struct{}
25

26
// Creates new command reasoner.
27
func NewCmd() *Cmd {
1✔
28
        return &Cmd{}
1✔
29
}
1✔
30

NEW
31
func (task *Cmd) Purge() {}
×
32

33
func (task *Cmd) Deduct(state StateCmd) (thinker.Phase, chatter.Prompt, error) {
1✔
34
        if state.Feedback != nil && state.Confidence < 1.0 {
2✔
35
                var prompt chatter.Prompt
1✔
36
                prompt.WithTask("Refine the previous operation using the feedback below.")
1✔
37
                prompt.With(state.Feedback)
1✔
38

1✔
39
                return thinker.AGENT_REFINE, prompt, nil
1✔
40
        }
1✔
41

42
        if len(state.Reply.Cmd) != 0 {
2✔
43
                return thinker.AGENT_RETURN, chatter.Prompt{}, nil
1✔
44
        }
1✔
45

46
        return thinker.AGENT_ABORT, chatter.Prompt{}, thinker.ErrUnknown
1✔
47
}
48

49
//------------------------------------------------------------------------------
50

51
// The sequence of cmd (commands) reasoner set the goal for agent to execute a sequence of commands.
52
// The reason returns only after LLM uses return command.
53
type CmdSeq struct{}
54

55
func NewCmdSeq() *CmdSeq {
1✔
56
        return &CmdSeq{}
1✔
57
}
1✔
58

NEW
59
func (task *CmdSeq) Purge() {}
×
60

61
func (task *CmdSeq) Deduct(state StateCmd) (thinker.Phase, chatter.Prompt, error) {
1✔
62
        if state.Feedback != nil && state.Confidence < 1.0 {
2✔
63
                var prompt chatter.Prompt
1✔
64
                prompt.WithTask("Refine the previous workflow step using the feedback below.")
1✔
65
                prompt.With(state.Feedback)
1✔
66

1✔
67
                return thinker.AGENT_REFINE, prompt, nil
1✔
68
        }
1✔
69

70
        if state.Reply.Cmd == command.RETURN {
2✔
71
                return thinker.AGENT_RETURN, chatter.Prompt{}, nil
1✔
72
        }
1✔
73

74
        // the workflow step is completed
75
        if len(state.Reply.Cmd) != 0 {
2✔
76
                var prompt chatter.Prompt
1✔
77
                prompt.WithTask("Continue the workflow execution.")
1✔
78
                prompt.With(
1✔
79
                        chatter.Blob(
1✔
80
                                fmt.Sprintf("TOOL:%s has returned:\n", state.Reply.Cmd),
1✔
81
                                state.Reply.Output,
1✔
82
                        ),
1✔
83
                )
1✔
84

1✔
85
                return thinker.AGENT_ASK, prompt, nil
1✔
86
        }
1✔
87

88
        return thinker.AGENT_ABORT, chatter.Prompt{}, thinker.ErrUnknown
1✔
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc