Commit graph

22002 commits

Author SHA1 Message Date
Nick Misasi
1838ea84c5 chore: complete v1.1 LangChain Agent Demo milestone
Archived:
- milestones/v1.1-ROADMAP.md (phases 14-18, 5 plans)
- milestones/v1.1-REQUIREMENTS.md (9 requirements shipped)

Deleted (fresh for next milestone):
- ROADMAP.md

Updated:
- MILESTONES.md (added v1.1 entry with stats and accomplishments)
- PROJECT.md (updated tech stack, key decisions, last updated timestamp)
- STATE.md (ready for v1.2 planning)

v1.0 and v1.1 both shipped and archived. Ready for next milestone.
2026-01-21 10:55:51 -05:00
Nick Misasi
02054e60bd docs(18): complete phase verification
Phase 18: Agentic Loop
- 4/4 must-haves verified
- Recursion limit, extended thinking, tenacity retry all verified
- v1.1 milestone complete
2026-01-20 14:09:15 -05:00
Nick Misasi
a0a50fdc02 docs(18-01): complete agentic loop plan
Tasks completed: 3/3
- Add recursion limit to prevent infinite agent loops
- Enable extended thinking for Anthropic model
- Add graceful tool error handling with tenacity retry

SUMMARY: .planning/phases/18-agentic-loop/18-01-SUMMARY.md

Milestone v1.1 LangChain Agent Demo complete!
2026-01-20 14:06:48 -05:00
Nick Misasi
eff1402d23 feat(18-01): add graceful tool error handling with tenacity retry
- Added tenacity>=8.0.0 dependency for retry logic
- Created _invoke_agent_with_retry helper with @retry decorator
- Retries up to 3 times with exponential backoff (1-10 seconds)
- Retries only on ConnectionError and TimeoutError (transient)
- Graceful fallback to tool-less model on repeated failures
2026-01-20 14:05:21 -05:00
Nick Misasi
dee764f260 feat(18-01): enable extended thinking for Anthropic model
- ChatAnthropic now uses thinking={"type": "enabled", "budget_tokens": 2000}
- Increased max_tokens to 5000 to accommodate thinking + response
- Updated system prompt to leverage thoughtful reasoning
2026-01-20 14:04:33 -05:00
Nick Misasi
0334f2c6ad feat(18-01): add recursion limit to prevent infinite agent loops
- Agent invocation now uses config={"recursion_limit": 10}
- Limits ReAct agent to 10 reasoning iterations max
- Prevents infinite loops in complex multi-step tasks
2026-01-20 14:04:04 -05:00
Nick Misasi
a9c5e8f313 docs(18): create phase plan
Phase 18: Agentic Loop
- 1 plan in 1 wave
- All autonomous execution
- Ready for execution
2026-01-20 14:02:10 -05:00
Nick Misasi
1cc1d7dc79 fix(18): revise plan based on checker feedback
- Clarify multi-step execution scope: ReAct loop IS multi-step
- Reframe must_haves.truths to be user-observable behaviors
- Note orchestrator-worker patterns out of scope for demo
2026-01-20 14:01:30 -05:00
Nick Misasi
ebf424c65c fix(18): revise plan to use verified LangGraph and tenacity APIs
- Task 1: Use recursion_limit config param instead of non-existent middleware
- Task 2: Keep Anthropic thinking param (verified real)
- Task 3: Replace non-existent @wrap_tool_call with tenacity @retry
- Update must_haves to reference actual patterns
2026-01-20 13:59:19 -05:00
Nick Misasi
306240eb15 docs(18): create agentic loop phase plan
Phase 18: Agentic Loop
- 1 plan in 1 wave
- Adds middleware (ToolRetryMiddleware, ModelCallLimitMiddleware)
- Enables Anthropic extended thinking
- Implements graceful tool error handling
- Ready for execution
2026-01-20 13:56:01 -05:00
Nick Misasi
4aef9f497f docs(18): research phase domain
Phase 18: Agentic Loop
- Standard stack identified (langchain 1.0+, middleware system)
- Architecture patterns documented (create_agent, extended thinking, TodoListMiddleware)
- Pitfalls catalogued (iteration limits, thinking budget, context overflow)
- Extended thinking and middleware patterns verified via official docs
2026-01-20 13:53:15 -05:00
Nick Misasi
d0e8f53714 docs(17): verify MCP client phase complete 2026-01-20 13:47:52 -05:00
Nick Misasi
3f5256ecf9 docs(17-01): complete MCP client integration plan
Tasks completed: 2/2
- Add MCP dependencies and imports
- Initialize MCP client and convert handlers to async agents

SUMMARY: .planning/phases/17-mcp-client/17-01-SUMMARY.md
2026-01-20 13:45:38 -05:00
Nick Misasi
b5f5973521 feat(17-01): add MCP client initialization and async agent handlers
- Add _get_mcp_server_config() method for server configuration
- Initialize MCP client in on_activate() after model initialization
- Add async _handle_message_async() that uses create_react_agent with MCP tools
- Update _handle_openai_message and _handle_anthropic_message to use asyncio.run()
- Graceful fallback to basic model.invoke() when no MCP servers configured
2026-01-20 13:44:15 -05:00
Nick Misasi
994f016486 feat(17-01): add MCP dependencies and imports
- Add langchain-mcp-adapters>=0.2.0 and langgraph>=0.2.0 to requirements.txt
- Bump langchain to >=1.2.0 for MCP adapter compatibility
- Add asyncio, MultiServerMCPClient, create_react_agent imports
- Add mcp_client attribute to __init__
2026-01-20 13:42:50 -05:00
Nick Misasi
b21aa5d228 fix(17): revise plan based on checker feedback
- Task 1: Add langchain>=1.2.0 bump (was >=0.2.0)
- Task 1: Add note confirming create_react_agent accepts LangChain messages
- Task 2: Remove verify step 3 (plugin instantiation won't work outside runtime)
2026-01-20 13:40:02 -05:00
Nick Misasi
3f95965129 docs(17): create phase plan for MCP client integration
Phase 17: MCP Client
- 1 plan in 1 wave
- Add langchain-mcp-adapters and langgraph dependencies
- Initialize MultiServerMCPClient on activation
- Convert handlers to async with create_react_agent
- Graceful fallback when no MCP servers configured
- Ready for execution
2026-01-20 13:38:13 -05:00
Nick Misasi
c99e89c65b docs(17): research MCP client integration for LangChain plugin
Phase 17: MCP Client
- Standard stack: langchain-mcp-adapters>=0.2.0, mcp>=1.25.0, langgraph>=0.2.0
- Architecture patterns: MultiServerMCPClient, create_agent(), transport configs
- Transport options: HTTP (Streamable HTTP) and STDIO documented
- Common pitfalls: async context, subprocess lifecycle, session management
- Integration path with Phase 15 (LangChain Core) documented
2026-01-20 13:33:44 -05:00
Nick Misasi
544ed073cc docs(16): complete session memory phase
Phase 16: Session Memory
- 1 plan executed in 1 wave
- Threading and conversation history verified
- All must-haves passed
2026-01-20 13:11:51 -05:00
Nick Misasi
9c3a785aba docs(16-01): complete threading and conversation history plan
Tasks completed: 3/3
- Add threading to _send_response
- Build conversation history from thread
- Update handlers to use conversation history

SUMMARY: .planning/phases/16-session-memory/16-01-SUMMARY.md
2026-01-20 13:09:05 -05:00
Nick Misasi
f25d90e9c9 feat(16-01): update handlers to use conversation history
- OpenAI handler now uses _build_conversation_history
- Anthropic handler now uses _build_conversation_history
- Both handlers determine root_id and pass to response methods
- Bot remembers previous messages in thread conversations
- Updated bot_id type hint to accept str | None
2026-01-20 13:07:46 -05:00
Nick Misasi
5452456ebf feat(16-01): add conversation history builder from thread
- Import AIMessage from langchain_core.messages
- Add _build_conversation_history method
- Fetches thread posts and converts to LangChain message types
- User posts become HumanMessage, bot posts become AIMessage
- Graceful fallback if thread fetch fails
2026-01-20 13:07:05 -05:00
Nick Misasi
ced3c57ccb feat(16-01): add threading support to response methods
- Added root_id parameter to _send_response method
- Added root_id parameter to _send_error_response method
- Post creation now includes root_id for threaded replies
2026-01-20 13:06:35 -05:00
Nick Misasi
02f985632a docs(16): create phase plan for session memory
Phase 16: Session Memory
- 1 plan in 1 wave
- Threading responses via root_id
- Conversation history from Mattermost threads
- Ready for execution
2026-01-20 13:03:20 -05:00
Nick Misasi
49508e9df3 docs(15-01): complete LangChain core integration plan
Tasks completed: 2/2
- Add LangChain dependencies and model initialization
- Replace placeholder handlers with LangChain invocation

SUMMARY: .planning/phases/15-langchain-core/15-01-SUMMARY.md
2026-01-20 11:52:46 -05:00
Nick Misasi
5f2f3c261b feat(15-01): replace placeholder handlers with LangChain invocation
- Replace _handle_openai_message with real LangChain model.invoke()
- Replace _handle_anthropic_message with real LangChain model.invoke()
- Add _send_response helper for posting messages
- Add _send_error_response helper for error messages
- Check for None model before invocation (missing API key)
- Wrap API calls in try/except with user-friendly error messages
2026-01-20 11:51:06 -05:00
Nick Misasi
39a370b177 feat(15-01): add LangChain dependencies and model initialization
- Add langchain, langchain-openai, langchain-anthropic to requirements.txt
- Import ChatOpenAI, ChatAnthropic, and message types
- Add openai_model and anthropic_model instance variables
- Initialize models in on_activate with error handling for missing API keys
2026-01-20 11:50:17 -05:00
Nick Misasi
b7e004859a docs(15): create phase plan
Phase 15: LangChain Core
- 1 plan in 1 wave
- All autonomous (no checkpoints)
- User setup: OpenAI and Anthropic API keys required
- Ready for execution
2026-01-20 11:46:25 -05:00
Nick Misasi
5edc4b603d docs(16): capture phase context
Phase 16: Session Memory
- Implementation decisions documented
- Phase boundary established
2026-01-20 11:45:56 -05:00
Nick Misasi
b067ac58d5 docs(15): research LangChain core integration
Phase 15: LangChain Core
- Identified standard stack: langchain, langchain-openai, langchain-anthropic
- Documented provider factory and direct model patterns
- Catalogued common pitfalls (API keys, blocking, message types)
- Verified Phase 16-18 compatibility with memory and MCP

Sources: LangChain official docs, PyPI packages (v1.2.6, v1.1.7, v1.3.1)
2026-01-20 11:42:10 -05:00
Nick Misasi
7c832b87bf docs(14): complete Bot Infrastructure phase 2026-01-20 11:34:25 -05:00
Nick Misasi
abd48577ed docs(14-01): complete Bot Infrastructure plan
Tasks completed: 3/3
- Create plugin structure with manifest
- Create plugin class with bot creation on activation
- Implement DM message routing

SUMMARY: .planning/phases/14-bot-infrastructure/14-01-SUMMARY.md

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:31:45 -05:00
Nick Misasi
6750a88eed feat(14-01): implement DM message routing to bot handlers
- Add MessageHasBeenPosted hook for message routing
- Check channel type for DM detection
- Route messages based on bot membership in channel
- Add _handle_openai_message stub with placeholder response
- Add _handle_anthropic_message stub with placeholder response
- Include proper error handling for API calls

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:30:44 -05:00
Nick Misasi
9a27ea5bcb feat(14-01): implement bot creation on plugin activation
- Create LangChainAgentPlugin class with OnActivate/OnDeactivate hooks
- Add OpenAI bot (langchain-openai-agent) creation
- Add Anthropic bot (langchain-anthropic-agent) creation
- Store bot IDs as instance attributes for message routing
- Include proper error handling and logging

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:30:10 -05:00
Nick Misasi
c83ec9656e feat(14-01): create LangChain Agent plugin structure
- Add plugin.json manifest with plugin metadata
- Add requirements.txt with placeholder for future LangChain deps
- Add Makefile with venv, dist, clean targets

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:29:39 -05:00
Nick Misasi
3ae1ea0d33 docs(14): create phase plan for bot infrastructure
Phase 14: Bot Infrastructure
- 1 plan created
- 3 tasks defined
- Ready for execution

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:16:42 -05:00
Nick Misasi
d57965a5b2 docs: create milestone v1.1 LangChain Agent Demo (5 phases)
Phases:
- 14. bot-infrastructure: Create bots on activation, DM routing
- 15. langchain-core: LangChain setup with OpenAI/Anthropic providers
- 16. session-memory: Per-DM conversation history with KV store
- 17. mcp-client: MCP integration for external tools
- 18. agentic-loop: Tool calling orchestration and reasoning

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:12:46 -05:00
Nick Misasi
fcb404b4d6 chore: complete v1.0 milestone
- Created MILESTONES.md entry with accomplishments and stats
- Evolved PROJECT.md with validated requirements and current state
- Reorganized ROADMAP.md with milestone grouping
- Created milestone archive: milestones/v1.0-ROADMAP.md
- Updated STATE.md with milestone completion status

v1.0 Python Plugin Support shipped:
- 236 RPC methods for Plugin API
- 35+ hooks including ServeHTTP streaming
- Python SDK with typed client and decorator-based hooks
- Full server integration

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:57:39 -05:00
Nick Misasi
29267b6503 docs(13): complete Phase 13 - Python Plugin Developer Experience
Phase 13 completed with 4 plans via parallel execution:
- 13-01: Architecture documentation (ARCHITECTURE.md)
- 13-02: Server Makefile gRPC tooling (proto-gen-all)
- 13-03: Example plugin Makefile and packaging (dist target)
- 13-04: CLAUDE.md files for agentic AI development

MILESTONE COMPLETE: All 13 phases finished
- 41 plans total across 13 phases
- Full API parity (236 RPC methods)
- Full hook parity (35+ hooks)
- Complete developer documentation and tooling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:43:46 -05:00
Nick Misasi
f426b7a1ff docs(13-04): complete claude.md files plan
Add summary documenting creation of three CLAUDE.md files for agentic
AI development guidance targeting plugin developers, SDK maintainers,
and Mattermost contributors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:42:27 -05:00
Nick Misasi
0fda377dec docs(13-04): create server gRPC CLAUDE.md
Add AI development guidance for Mattermost contributors working on the
Python plugin gRPC infrastructure. Includes directory structure, key
components, proto organization, common patterns, and instructions for
adding new API methods and hooks.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:42:03 -05:00
Nick Misasi
a8dffb8e34 docs(13-04): create Python SDK CLAUDE.md
Add AI development guidance for SDK maintainers. Includes directory
structure, key components, development workflow, proto code generation,
and instructions for adding new hooks and API methods.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:41:31 -05:00
Nick Misasi
9b43bb3542 docs(13-04): create example plugin CLAUDE.md
Add AI development guidance for plugin developers using the hello_python
example as a template. Includes setup commands, architecture overview,
hook patterns, API usage, and best practices.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:41:03 -05:00
Nick Misasi
076d9c9aef docs(13-01): complete architecture documentation plan
Add execution summary for plan 13-01 (Architecture Documentation).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:39:27 -05:00
Nick Misasi
f1f1ee8d95 docs(13-01): create comprehensive gRPC architecture documentation
Add ARCHITECTURE.md documenting the Python plugin gRPC system including:
- High-level overview and ASCII system architecture diagram
- Component layer documentation (Protocol, Go Infrastructure, Python SDK)
- Process lifecycle (loading, environment variables, shutdown)
- Communication flow diagrams (hooks, API calls, ServeHTTP streaming)
- Key design decisions (embedded AppError, 64KB chunks, APIServerRegistrar)
- Complete file reference table mapping functionality to source files
- Extension guide for adding new API methods and hooks

This documentation enables internal Mattermost engineers to understand,
debug, and extend the Python plugin infrastructure.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:38:52 -05:00
Nick Misasi
f7f89df63a docs(13-03): complete example plugin makefile plan
Add summary documenting:
- Makefile creation with development workflow targets
- Plugin packaging verification (dist, dist-minimal, clean, help)
- Template serves as reference for Python plugin developers

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:38:15 -05:00
Nick Misasi
1abf9291ec docs(13-02): complete server makefile tooling plan
Add summary for 13-02 plan execution:
- Task 1: Added python-proto-gen and proto-gen-all targets to server Makefile
- Task 2: Created Python SDK Makefile with venv, proto-gen, build, test, lint, clean targets

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:37:56 -05:00
Nick Misasi
8cc1f0b490 feat(13-02): create Python SDK Makefile with dev workflow targets
Add Makefile to python-sdk/ with targets for common development operations:

- venv: Create virtual environment and install dependencies
- proto-gen: Generate Python gRPC code from proto files
- build: Build SDK package (wheel and sdist)
- test: Run pytest test suite
- lint: Run mypy type checking
- clean: Remove build artifacts
- help: Show available targets

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:37:24 -05:00
Nick Misasi
feec91ade1 feat(13-03): create example plugin Makefile with all targets
Add Makefile for hello_python example with development workflow targets:
- venv: Create virtual environment with SDK and dependencies
- install: Install/update dependencies in existing venv
- dist: Package plugin as tar.gz with vendored SDK
- dist-minimal: Package plugin without SDK (server must have SDK)
- clean: Remove build artifacts
- run: Run plugin locally for testing
- lint: Run type checking on plugin code
- help: Show available targets and development workflow

This Makefile serves as a template for Python plugin developers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:37:08 -05:00
Nick Misasi
a049f81c76 feat(13-02): add Python proto generation targets to server Makefile
Add python-proto-gen and proto-gen-all targets to server/public/Makefile
for complete gRPC code generation workflow:

- python-proto-gen: Generates Python gRPC code by calling generate_protos.py
- proto-gen-all: Runs both Go and Python proto generation in sequence

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 10:37:03 -05:00