diff options
| author | Ben Sima <ben@bensima.com> | 2025-12-19 16:41:01 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bensima.com> | 2025-12-19 16:41:01 -0500 |
| commit | e856c766584ed933bed0b79c7ef47b6d98b0fb7e (patch) | |
| tree | a630081a106678533837c8e284d04146b2593cb5 /Omni/Agent/Telegram.hs | |
| parent | 37d6503342ef9e171fef88960f7baceaa4d1a641 (diff) | |
Omni/Agent: wire prompt templating system to agents
- Telegram.hs: add loadTelegramSystemPrompt with fallback
- Subagent.hs: add loadSystemPromptForRole with fallback
- Coder.hs: add loadCoderSystemPrompt with fallback
- Ava.nix: add tmpfiles rules for /home/ava/prompts/
- Prompts.hs: fix test to expect .mustache extension
Templates loaded at runtime from $AVA_DATA_ROOT/prompts/.
Falls back to hardcoded prompts if templates not found.
Amp-Thread-ID: https://ampcode.com/threads/T-019b3878-73be-77ec-97cc-d092a28d211e
Co-authored-by: Amp <amp@ampcode.com>
Diffstat (limited to 'Omni/Agent/Telegram.hs')
| -rw-r--r-- | Omni/Agent/Telegram.hs | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Omni/Agent/Telegram.hs b/Omni/Agent/Telegram.hs index 0ebf4ca..7b2beaa 100644 --- a/Omni/Agent/Telegram.hs +++ b/Omni/Agent/Telegram.hs @@ -13,7 +13,9 @@ -- -- : out omni-agent-telegram -- : dep aeson +-- : dep directory -- : dep http-conduit +-- : dep mustache -- : dep stm -- : dep HaskellNet -- : dep HaskellNet-SSL @@ -85,6 +87,7 @@ import qualified Omni.Agent.AuditLog as AuditLog import qualified Omni.Agent.Engine as Engine import qualified Omni.Agent.Memory as Memory import qualified Omni.Agent.Paths as Paths +import qualified Omni.Agent.Prompts as Prompts import qualified Omni.Agent.Provider as Provider import qualified Omni.Agent.Skills as Skills import qualified Omni.Agent.Subagent as Subagent @@ -154,8 +157,20 @@ test = benChatId :: Int benChatId = 33193730 +-- | Load system prompt from template, falling back to hardcoded if unavailable +loadTelegramSystemPrompt :: IO Text +loadTelegramSystemPrompt = do + result <- Prompts.renderPrompt "agents/telegram/system" (Aeson.object []) + case result of + Right prompt -> pure prompt + Left _err -> pure telegramSystemPromptFallback + +-- | Hardcoded fallback prompt (used if template not found) telegramSystemPrompt :: Text -telegramSystemPrompt = +telegramSystemPrompt = telegramSystemPromptFallback + +telegramSystemPromptFallback :: Text +telegramSystemPromptFallback = Text.unlines [ "don't worry about formalities. respond conversationally, in short messages, not long essays. ask follow up questions before answering if you need to.", "", @@ -1100,8 +1115,11 @@ processEngagedMessage tgConfig provider engineCfg msg uid userName chatId userMe "prioritize: urgent items first, then emails needing response, then suggest unsubscribing from marketing." ] else "" - systemPrompt = - telegramSystemPrompt + + basePrompt <- loadTelegramSystemPrompt + + let systemPrompt = + basePrompt <> "\n\n## Current Date and Time\n" <> timeStr <> chatContext |
