// bytes, and a sample line as the ruler gets its content copied.
var compactorRuler = strings.Repeat("-", nodeBytes)
-// newCompactor returns the compactor of an agent, which sends its calls through
-// client with model. instructions gives the system prompt of the agent at each
-// build. tools are the tools of that agent, so a build sends the same prompt
-// and tools as its turns.
-func newCompactor(client *ModelClient, instructions func() (string, error), model ModelConfig, tools []ModelTool, images *ImageStore) *Compactor {
- return &Compactor{
- client: client,
- model: model,
- instructions: instructions,
- tools: tools,
- images: images,
- }
-}
-
// Compactor builds the nodes of one agent with a model. A compaction is a call
// like a turn, with the same system prompt and tools, so it reads them from the
// prompt cache of the turns. The tools are never called. After them comes one
images *ImageStore
}
+// newCompactor returns the compactor of an agent, which sends its calls through
+// client with model. instructions gives the system prompt of the agent at each
+// build. tools are the tools of that agent, so a build sends the same prompt
+// and tools as its turns.
+func newCompactor(client *ModelClient, instructions func() (string, error), model ModelConfig, tools []ModelTool, images *ImageStore) *Compactor {
+ return &Compactor{
+ client: client,
+ model: model,
+ instructions: instructions,
+ tools: tools,
+ images: images,
+ }
+}
+
// Summarize returns the line of the node of task.
func (c *Compactor) Summarize(ctx context.Context, task Task) (string, error) {
text, err := compactorTask(task)
<input>
%s
</input>`, task.Index, nodeBytes, compactorRuler, task.Input[0])
+
if len(task.Images) > 0 {
text += "\nKeep each [image FILE] name and describe its kind, visible text, amounts, names, and context."
}