tools.goal_tools module
Channel Goal Management Tools (v3)
Per-channel long-term goals with sub-task tracking, stored in Redis.
- async tools.goal_tools.get_channel_goals_for_prompt(target_channel_id, *, redis_client=None, ctx=None)[source]
Return a simplified, sorted goal list for system-prompt injection.
Reads every goal stored under
stargazer:goal:<channel>:*for the given channel from Redis (batched through a single pipeline to avoid N-1 round trips), then flattens each goal into a compact dict with a computed completion percentage and a"<done>/<total> tasks completed"summary, sorted by priority then creation time. The trimmed shape exists so the runtime prompt assembly can surface active channel goals to the model without dumping full sub-task payloads. Any error is swallowed and logged, returning an empty list so prompt rendering never fails on goal data.Accepts either an explicit
redis_clientor actx(from which the client is resolved via_redis). Called byprompt_context.pywhile assembling runtime prompt context (imported lazily astools.goal_tools.get_channel_goals_for_prompt); no other callers.- Parameters:
target_channel_id (
str) – Channel whose goals to fetch.redis_client – Pre-resolved async Redis client; takes precedence over
ctxwhen provided.ctx – Tool execution context used to resolve a Redis client when
redis_clientisNone.
- Return type:
- Returns:
A list of simplified goal dicts (goal id, title, description, priority, completion flag, progress percent, sub-task summary, timestamps), ordered by priority then creation time; empty if there are no goals, no client, or an error occurs.