Commit 34431ec
authored
feat: tell MCP which porject it should use (#784)
### TL;DR
Added PostHog project context to the system prompt for agent sessions.
### What changed?
- Created a new `buildPostHogSystemPrompt` method that generates a system prompt with PostHog project context
- Added the PostHog system prompt to both new sessions and resumed sessions
- Added support for a `POSTHOG_MCP_URL` environment variable to override the MCP URL
- Modified the logic for determining the PostHog MCP URL to prioritize the environment variable
### How to test?
1. Set the `POSTHOG_MCP_URL` environment variable to test the override functionality
2. Start a new agent session and verify that the PostHog project context is included in the system prompt
3. Resume an existing session and confirm the context is maintained
### Why make this change?
This change ensures that the agent has proper context about which PostHog project it should operate on. By including the project ID and API host in the system prompt, the agent can make more accurate decisions when using PostHog MCP tools, preventing accidental cross-project operations.1 parent 92f47ed commit 34431ec
2 files changed
Lines changed: 18 additions & 5 deletions
File tree
- apps/twig/src/main/services/agent
- packages/agent/src/adapters/claude
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
350 | 358 | | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
356 | 364 | | |
357 | 365 | | |
358 | 366 | | |
| |||
475 | 483 | | |
476 | 484 | | |
477 | 485 | | |
| 486 | + | |
478 | 487 | | |
479 | 488 | | |
480 | 489 | | |
| |||
486 | 495 | | |
487 | 496 | | |
488 | 497 | | |
| 498 | + | |
489 | 499 | | |
490 | 500 | | |
491 | 501 | | |
| |||
505 | 515 | | |
506 | 516 | | |
507 | 517 | | |
| 518 | + | |
508 | 519 | | |
509 | 520 | | |
510 | 521 | | |
511 | 522 | | |
512 | 523 | | |
513 | 524 | | |
| 525 | + | |
514 | 526 | | |
515 | 527 | | |
516 | 528 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
210 | 211 | | |
211 | 212 | | |
212 | 213 | | |
| |||
0 commit comments