@fickydev/pigent 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -39,6 +39,12 @@
39
39
  - Added safe Pi runner failure replies with internal error persistence.
40
40
  - Added per-session locking to serialize Pi runs for the same agent/channel/chat/thread.
41
41
  - Added Telegram chat instructions to Pi prompt composition.
42
+ - Added Telegram API retry/backoff for transient network, rate limit, and server errors.
43
+ - Planned model selection support across profile, agent, and Telegram chat override levels.
44
+ - Added profile and agent config-based Pi model and thinking level selection.
45
+ - Added session-scoped model and thinking level overrides with `/model` and `/thinking` Telegram commands.
46
+ - Planned Telegram inline-button model and thinking level pickers backed by configured model choices.
47
+ - Added Telegram inline-button pickers for `/model` and `/thinking`, callback handling, and bot command menu registration.
42
48
  - Kept daemon process alive after startup so CLI runs do not exit after `pigent ready`.
43
49
 
44
50
  ### Changed
package/PLAN.md CHANGED
@@ -61,7 +61,8 @@ Profile defines reusable behavior shared by agents.
61
61
 
62
62
  Profile may include:
63
63
 
64
- - model preference
64
+ - model preference using `provider/modelId`
65
+ - thinking level preference (`off`, `low`, `medium`, `high`)
65
66
  - base system prompt
66
67
  - response style
67
68
  - default skills
@@ -152,6 +153,8 @@ Each Telegram group/private chat can define:
152
153
  - default agent
153
154
  - allowed agents
154
155
  - custom instructions
156
+ - per-agent model override via Telegram command
157
+ - per-agent thinking level override via Telegram command
155
158
  - heartbeat settings
156
159
  - enabled/disabled status
157
160
 
@@ -170,6 +173,61 @@ telegramChats:
170
173
  This is engineering group. Be concise. Prefer TypeScript.
171
174
  ```
172
175
 
176
+ ## Model Selection
177
+
178
+ Pigent should support model selection at multiple levels without exposing provider secrets to channel prompts.
179
+
180
+ Model identifiers use Pi SDK `provider/modelId` format, for example:
181
+
182
+ ```text
183
+ anthropic/claude-opus-4-5
184
+ openai/gpt-4.1
185
+ ollama/qwen2.5-coder:7b
186
+ ```
187
+
188
+ Selection priority:
189
+
190
+ ```text
191
+ session override > agent config > profile config > Pi default
192
+ ```
193
+
194
+ A session is keyed by `agentId + channel + chatId + threadId`, so the same agent can use different models in private chats, group chats, and Telegram forum topics.
195
+
196
+ Config support should come first:
197
+
198
+ - `profiles/*.yaml` may define `model` and `thinkingLevel`
199
+ - `agents/*/agent.yaml` may override `model` and `thinkingLevel`
200
+
201
+ Telegram command support should persist session-scoped overrides after config support exists:
202
+
203
+ - `/model` shows current model for the default agent in the chat
204
+ - `/model <provider/modelId>` sets model for the default agent session in the current chat/thread
205
+ - `/model default` clears model override for the default agent session in the current chat/thread
206
+ - `/thinking <level>` sets thinking level for the default agent session in the current chat/thread
207
+ - `/thinking default` clears thinking override for the default agent session in the current chat/thread
208
+
209
+ Telegram should also provide inline-button pickers so non-technical users can choose from configured choices:
210
+
211
+ - `/model` can reply with inline keyboard buttons for configured model choices plus `Use default`
212
+ - `/thinking` can reply with inline keyboard buttons for `Off`, `Low`, `Medium`, `High`, and `Use default`
213
+ - callback payloads should be short and action-scoped, such as `model:set:<choiceId>`, `model:default`, `thinking:set:medium`, and `thinking:default`
214
+ - after selection, bot should answer the callback and update or send a confirmation message
215
+ - daemon startup should register Telegram bot commands through `setMyCommands` so users see Pigent commands in the Telegram command menu
216
+
217
+ Model choices should be explicitly configured instead of exposing every Pi model blindly:
218
+
219
+ ```yaml
220
+ modelChoices:
221
+ - id: anthropic/claude-sonnet-4-5
222
+ label: Claude Sonnet
223
+ - id: anthropic/claude-opus-4-5
224
+ label: Claude Opus
225
+ - id: openai/gpt-4.1
226
+ label: GPT-4.1
227
+ ```
228
+
229
+ The command and callback handlers should validate agent access and model availability through a Pi model resolver. They must not reveal API keys, auth values, raw environment variables, or provider secrets.
230
+
173
231
  ## Prompt Composition
174
232
 
175
233
  For each request, compose context from:
@@ -195,6 +253,7 @@ Initial entities:
195
253
  - telegram chat agents
196
254
  - messages
197
255
  - heartbeats
256
+ - session model/thinking overrides
198
257
  - tasks/events later
199
258
 
200
259
  SQLite first. Keep schema types portable so PostgreSQL migration is straightforward.
@@ -319,6 +378,8 @@ drizzle/
319
378
  ### Milestone 6: Pi Runner
320
379
 
321
380
  - create Pi SDK sessions
381
+ - resolve profile/agent model preferences
382
+ - resolve chat model overrides
322
383
  - send prompts
323
384
  - return responses
324
385
  - persist inbound/outbound messages
@@ -362,6 +423,8 @@ Add Hono only after daemon works. Use it for:
362
423
 
363
424
  ## Open Questions
364
425
 
426
+ - Should `/model <agentId> ...` support non-default agent sessions in the command itself?
427
+ - Should model availability errors block `/model` saves or save with a warning?
365
428
  - Which Pi SDK session manager should be used for persistent sessions?
366
429
  - How exactly should per-agent skills/extensions be loaded into Pi runtime?
367
430
  - Should group instructions live in YAML, DB, or both?
package/TODO.md CHANGED
@@ -39,6 +39,10 @@
39
39
 
40
40
  ## Config
41
41
 
42
+ - [x] Add root `modelChoices` config for Telegram model picker buttons
43
+ - [x] Add profile-level `thinkingLevel` config
44
+ - [x] Add agent-level `model` override config
45
+ - [x] Add agent-level `thinkingLevel` override config
42
46
  - [x] Define root config format
43
47
  - [x] Define `AgentConfig`
44
48
  - [x] Define `ProfileConfig`
@@ -66,6 +70,8 @@
66
70
  - [x] Define `messages` table
67
71
  - [x] Define `heartbeats` table
68
72
  - [x] Define `runtime_kv` table for offsets and daemon state
73
+ - [x] Add `agent_sessions.model` for session model override
74
+ - [x] Add `agent_sessions.thinking_level` for session thinking override
69
75
  - [x] Implement repositories
70
76
  - [x] `AgentRepository`
71
77
  - [x] `SessionRepository`
@@ -79,11 +85,15 @@
79
85
  - [x] Define `OutboundMessage`
80
86
  - [x] Define `ChannelAdapter`
81
87
  - [x] Define Telegram normalized types
88
+ - [x] Normalize Telegram callback query updates
82
89
  - [ ] Implement `TelegramApi`
83
90
  - [x] `getUpdates`
84
91
  - [x] `sendMessage`
85
92
  - [x] error handling
86
- - [ ] retry/backoff
93
+ - [x] retry/backoff
94
+ - [x] `answerCallbackQuery`
95
+ - [x] inline keyboard `reply_markup` support
96
+ - [x] `setMyCommands` Telegram command menu registration
87
97
  - [x] Implement `TelegramPollingAdapter`
88
98
  - [x] polling loop
89
99
  - [x] offset tracking
@@ -121,6 +131,12 @@
121
131
 
122
132
  ## Pi Integration
123
133
 
134
+ - [x] Confirm SDK model selection supports `createAgentSession({ model, thinkingLevel })`
135
+ - [x] Implement Pi model resolver for `provider/modelId`
136
+ - [x] Apply profile-level model selection
137
+ - [x] Apply agent-level model override
138
+ - [x] Apply session model override
139
+ - [x] Apply thinking level selection
124
140
  - [x] Confirm SDK APIs needed for session creation
125
141
  - [ ] Confirm persistent session manager approach
126
142
  - [ ] Confirm per-agent system prompt injection
@@ -162,6 +178,19 @@
162
178
  - [ ] `/sessions` list active sessions for chat
163
179
  - [ ] `/reset-session <agentId>` clear chat session
164
180
  - [ ] `/heartbeat status` show heartbeat state
181
+ - [x] `/model` show current model for default chat agent session
182
+ - [x] `/model <provider/modelId>` set model for default chat agent session
183
+ - [x] `/model default` clear model for default chat agent session
184
+ - [x] `/thinking` show thinking level for default chat agent session
185
+ - [x] `/thinking <level>` set thinking level for default chat agent session
186
+ - [x] `/thinking default` clear thinking level for default chat agent session
187
+ - [x] `/model` inline button picker for configured model choices
188
+ - [x] `/thinking` inline button picker
189
+ - [x] Handle model picker callback and persist selected session model
190
+ - [x] Handle thinking picker callback and persist selected session thinking level
191
+ - [x] Add `Use default` model/thinking buttons
192
+ - [ ] `/model <agentId> <provider/modelId>` set model for an explicit agent session
193
+ - [ ] `/thinking <agentId> <level>` set thinking level for an explicit agent session
165
194
  - [x] `/help` show bot commands
166
195
 
167
196
  ## Tests
@@ -171,6 +200,10 @@
171
200
  - [ ] Unit test routing rules
172
201
  - [ ] Unit test session key generation
173
202
  - [ ] Unit test heartbeat `NOOP` behavior
203
+ - [ ] Unit test model selection priority
204
+ - [ ] Unit test Telegram `/model` command parsing
205
+ - [ ] Unit test Telegram model picker callback parsing
206
+ - [ ] Unit test Telegram thinking picker callback parsing
174
207
  - [ ] Repository tests against temp SQLite DB
175
208
  - [ ] Integration test fake Telegram update to fake Pi runner
176
209
 
@@ -1,6 +1,8 @@
1
1
  id: assistant
2
2
  name: Assistant
3
3
  profile: generic-assistant
4
+ model: null
5
+ thinkingLevel: null
4
6
  workspace: ~/.pigent/workspaces/assistant
5
7
  systemPromptFile: ./SYSTEM.md
6
8
  skills: []
@@ -0,0 +1,2 @@
1
+ ALTER TABLE `agent_sessions` ADD `model` text;--> statement-breakpoint
2
+ ALTER TABLE `agent_sessions` ADD `thinking_level` text;