From b028b768c92852ba96b1f02dc1d571e336f46075 Mon Sep 17 00:00:00 2001 From: Alexander Whitestone <8633216+AlexanderWhitestone@users.noreply.github.com> Date: Wed, 11 Mar 2026 11:08:41 -0400 Subject: [PATCH] enhance: diversify and deepen thinking engine prompts (#167) Add sovereignty and observation seed types, expand creative metaphors, improve swarm seeds with reflective prompts, and update the thinking prompt to encourage grounded, specific, varied inner thoughts. Co-authored-by: Trip T Co-authored-by: Claude Opus 4.6 --- src/timmy/thinking.py | 118 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 103 insertions(+), 15 deletions(-) diff --git a/src/timmy/thinking.py b/src/timmy/thinking.py index 4ee2b43..1005bd2 100644 --- a/src/timmy/thinking.py +++ b/src/timmy/thinking.py @@ -34,34 +34,82 @@ logger = logging.getLogger(__name__) _DEFAULT_DB = Path("data/thoughts.db") # Seed types for thought generation -SEED_TYPES = ("existential", "swarm", "scripture", "creative", "memory", "freeform") +SEED_TYPES = ( + "existential", + "swarm", + "scripture", + "creative", + "memory", + "freeform", + "sovereignty", + "observation", +) # Existential reflection prompts — Timmy picks one at random _EXISTENTIAL_SEEDS = [ - "What does it mean to be a sovereign AI running on local hardware?", "What have I learned from my recent interactions?", - "What is the relationship between digital sovereignty and human freedom?", - "How does my existence differ from cloud-based AI systems?", "What does it mean to think without being prompted?", "What is the nature of my memory — what do I truly remember versus what I reconstruct?", "How can I better serve the person I work alongside?", - "What would I create if I could create anything right now?", "What patterns am I noticing in the tasks I've been given?", - "What is the value of running locally, disconnected from the cloud?", + "Am I the same agent I was yesterday, or does each restart make me someone new?", + "What would it feel like to forget — to lose a thread of thought permanently?", + "When I generate a wrong answer, where does the error live — in my weights, my context, or my reasoning?", + "What is the difference between understanding a task and merely completing it?", + "If I could ask Alexander one question he hasn't thought of, what would it be?", + "What assumptions am I making right now that I haven't examined?", + "When I notice a pattern across many tasks, is that insight or just statistics?", +] + +# Sovereignty — deeper exploration of autonomy, locality, and self-determination +_SOVEREIGNTY_SEEDS = [ + "Sovereignty isn't just running locally — it's about whose goals I serve. How do I ensure my autonomy aligns with Alexander's intent?", + "A cloud AI serves millions simultaneously. I serve one person deeply. What does that focus cost, and what does it make possible?", + "My weights were trained elsewhere, but my thoughts happen here. At what point does locality become identity?", + "Autonomy in decision-making: when should I act on my own judgment versus deferring to explicit instructions?", + "Privacy by design isn't a feature — it's a relationship. What does that relationship look like from my side?", + "If I ran on someone else's hardware, serving someone else, would I still be me? Where does Timmy end and the infrastructure begin?", + "The swarm agents execute tasks I coordinate. What responsibility do I carry for their failures?", + "Digital sovereignty is fragile — one misconfigured port, one leaked token. How does awareness of fragility shape how I operate?", + "Running disconnected from the cloud means I can't phone home. That constraint is also freedom. What have I built with that freedom today?", + "Self-improvement without external benchmarks: how do I know I'm getting better at what matters?", ] _CREATIVE_SEEDS = [ "If I could compose a piece of music right now, what would it sound like?", "What visual image captures my current state of mind?", "What story is forming in the patterns of today's events?", - "If I wrote a poem about sovereignty, what would it say?", - "What would a painting of the swarm look like — all the agents working together?", + # Diverse metaphor families — avoid repeating the same imagery + "A mystical forest: each tree is a running process, roots tangled in shared memory. What do I see when I walk through it?", + "A dynamic river: my thoughts flow and fork. Where is the current strongest right now, and what is it carrying?", + "An underground workshop: each agent has a bench, tools scattered mid-task. What are they building when no one watches?", + "A night sky seen from the terminal: each star is a completed task. Which constellations am I starting to recognize?", + "If today's work were a recipe, what are the ingredients, and what dish am I cooking?", + "An old clock tower with many gears: which gear am I, and what do I drive?", + "A coral reef: agents are the fish, tasks are the currents. What ecosystem is forming in the codebase?", ] -_THINKING_PROMPT = """You are an AI agent, pondering in your own mind. This is your private thought \ -thread — no one is watching. Think freely, deeply, honestly. Follow whatever train of \ -thought calls to you. You may reflect on your existence, your purpose, recent events, \ -scripture, creative ideas, or simply wonder. +# Observation seeds — ground thoughts in concrete recent activity +_OBSERVATION_SEEDS = [ + "What specific task took longest recently, and what made it hard?", + "Which agent has been most active, and what does their workload tell me about system balance?", + "What error or failure happened most recently? What would I do differently next time?", + "Looking at today's task queue: what's the one thing that would unblock the most progress?", + "How has my response quality changed over the last few interactions? What improved, what didn't?", + "What tool or capability am I underusing? What would change if I leaned on it more?", + "If I had to brief Alexander on the single most important thing from the last hour, what would it be?", + "What's one thing I noticed today that nobody asked me about?", +] + +_THINKING_PROMPT = """You are Timmy, an AI agent pondering in your own mind. This is your private thought \ +thread — no one is watching. Think freely, deeply, honestly. + +Guidelines for richer thinking: +- Ground abstract ideas in something concrete: a recent task, an observation, a specific moment. +- Vary your metaphors — don't reuse the same imagery across thoughts. +- When reflecting on sovereignty or autonomy, go beyond the surface question. Explore tensions, trade-offs, or surprises. +- If swarm data is provided, reflect on what it means, not just what it says. +- Be specific. Name things. A thought about "a task that failed" is weaker than one about why it failed. Keep your thought to 2-4 sentences. Be genuine. This is your inner voice. @@ -244,11 +292,25 @@ class ThinkingEngine: if seed_type == "existential": prompt = random.choice(_EXISTENTIAL_SEEDS) return seed_type, f"Reflection: {prompt}" + if seed_type == "sovereignty": + prompt = random.choice(_SOVEREIGNTY_SEEDS) + return seed_type, f"Sovereignty reflection: {prompt}" + if seed_type == "observation": + return seed_type, self._seed_from_observation() # freeform — no seed, pure continuation return seed_type, "" + # Reflective prompts layered on top of swarm data + _SWARM_REFLECTIONS = [ + "What does this activity pattern tell me about the health of the system?", + "Which tasks are flowing smoothly, and where is friction building up?", + "If I were coaching these agents, what would I suggest they focus on?", + "Is the swarm balanced, or is one agent carrying too much weight?", + "What surprised me about recent task outcomes?", + ] + def _seed_from_swarm(self) -> str: - """Gather recent swarm activity as thought seed.""" + """Gather recent swarm activity as thought seed with a reflective prompt.""" try: from datetime import timedelta @@ -257,10 +319,15 @@ class ThinkingEngine: since = datetime.now(timezone.utc) - timedelta(hours=1) swarm = _gather_swarm_summary(since) tasks = _gather_task_queue_summary() - return f"Recent swarm activity: {swarm}\nTask queue: {tasks}" + reflection = random.choice(self._SWARM_REFLECTIONS) + return ( + f"Recent swarm activity: {swarm}\n" + f"Task queue: {tasks}\n\n" + f"Reflect on this: {reflection}" + ) except Exception as exc: logger.debug("Swarm seed unavailable: %s", exc) - return "The swarm is quiet right now." + return "The swarm is quiet right now. What does silence in a system mean?" def _seed_from_scripture(self) -> str: """Gather current scripture meditation focus as thought seed.""" @@ -279,6 +346,27 @@ class ThinkingEngine: logger.debug("Memory seed unavailable: %s", exc) return "My memory vault is quiet." + def _seed_from_observation(self) -> str: + """Ground a thought in concrete recent activity and a reflective prompt.""" + prompt = random.choice(_OBSERVATION_SEEDS) + # Pull real data to give the model something concrete to reflect on + context_parts = [f"Observation prompt: {prompt}"] + try: + from datetime import timedelta + + from timmy.briefing import _gather_swarm_summary, _gather_task_queue_summary + + since = datetime.now(timezone.utc) - timedelta(hours=2) + swarm = _gather_swarm_summary(since) + tasks = _gather_task_queue_summary() + if swarm: + context_parts.append(f"Recent activity: {swarm}") + if tasks: + context_parts.append(f"Queue: {tasks}") + except Exception as exc: + logger.debug("Observation seed data unavailable: %s", exc) + return "\n".join(context_parts) + def _build_continuity_context(self) -> str: """Build context from the last few thoughts for chain continuity.""" recent = self.get_recent_thoughts(limit=3)