mirror of
https://github.com/pnx/dotfiles
synced 2026-08-20 10:38:12 +02:00
1.2 KiB
1.2 KiB
Best Practices & Limitations
Message Injection Workarounds
The Reality: The message system is largely read-only. You cannot mutate messages mid-stream or inject text directly into an existing message part.
What Doesn't Work
- Modifying
event.data.contentinmessage.updated. - Retroactively changing AI responses.
What Works
- Initial Context: Use
session.createdto inject a starting message usingclient.session.prompt(). - Prompt Decoration: Use
client.tui.appendPrompt()to add text to the user's input box before they hit enter. - Tool Interception: Use
tool.execute.beforeto modify arguments before the tool runs. - On-Demand Context: Provide custom tools that the AI can call when it needs more information.
Security
- Always validate tool inputs in
tool.execute.before. - Use environment variables for sensitive data; do not hardcode API keys.
- Be careful with the
$shell API to prevent command injection.
Performance
- Avoid heavy synchronous operations in event handlers as they can block the TUI.
- Use the
session.idleevent for cleanup or background sync tasks.