loop: add knowledge_base tool for on-demand information

The knowledge_base tool provides a way for agents to access specialized information
when needed. Initial topics include:

- sketch: how to use Sketch, including SSH, secrets, and file management
- go_iterators: information about Go's iterator feature added in Go 1.22

Co-Authored-By: sketch <hello@sketch.dev>
diff --git a/loop/agent.go b/loop/agent.go
index 81e1200..cc56f13 100644
--- a/loop/agent.go
+++ b/loop/agent.go
@@ -546,6 +546,10 @@
 	a.mu.Lock()
 	defer a.mu.Unlock()
 	a.branchName = branchName
+	convo, ok := a.convo.(*conversation.Convo)
+	if ok {
+		convo.ExtraData["branch"] = branchName
+	}
 }
 
 // OnToolCall implements ant.Listener and tracks the start of a tool call.
@@ -888,6 +892,7 @@
 	convo.PromptCaching = true
 	convo.Budget = a.config.Budget
 	convo.SystemPrompt = a.renderSystemPrompt()
+	convo.ExtraData = map[string]any{"session_id": a.config.SessionID}
 
 	// Define a permission callback for the bash tool to check if the branch name is set before allowing git commits
 	bashPermissionCheck := func(command string) error {
@@ -942,6 +947,10 @@
 		a.codereview.Tool(),
 	}
 
+	if experiment.Enabled("kb") {
+		convo.Tools = append(convo.Tools, claudetool.KnowledgeBase)
+	}
+
 	// One-shot mode is non-interactive, multiple choice requires human response
 	if !a.config.OneShot {
 		convo.Tools = append(convo.Tools, a.multipleChoiceTool())