Skip to content

Commit 6e69446

Browse files
authored
feat: add research agent with advanced Strands patterns (#170)
* feat: add autonomous research agent with advanced Strands patterns - Add comprehensive research agent sample (02-samples/14-research-agent) - Demonstrates hot-reloading tool development with instant availability - Implements multi-agent orchestration (tasks, use_agent, swarm, think) - Features persistent learning via SQLite memory and Bedrock Knowledge Base - Includes self-modifying system prompts for dynamic behavior adaptation - Showcases cascading intelligence patterns and relay chain coordination - Complete PyPI package with CLI entry points (strands-research-agent) - Production-ready with MCP integration and distributed event coordination - Comprehensive documentation with mermaid diagrams and usage examples - Specialized tools: event_bridge, graphql, scraper, s3_memory, sqlite_memory - Interactive callback handler with rich console output and notifications - Background task management with filesystem persistence - Meta-cognitive architecture demonstrating research-time scaling This sample represents advanced Strands Agents patterns for autonomous research systems that create tools, coordinate specialists, and learn across sessions - pushing the boundaries of what's possible with AI agents. * security: implement secure temporary directories and enhanced input validation - Replace insecure /tmp/.research/ usage with secure tempfile patterns - Add comprehensive input sanitization and validation across all tools - Implement SQL injection prevention with parameterized queries - Add secure file creation with proper permissions (0o600/0o700) - Enhance notification system with input validation and secure subprocess calls - Improve event_bridge with auto-infrastructure creation and better error handling - Add security patterns detection and validation in sqlite_memory tool BREAKING CHANGE: Temporary files now use secure temp directories instead of /tmp/.research/ * feat(security): eliminate SQL injection vulnerabilities and upgrade persistence architecture BREAKING CHANGE: Removed 7 vulnerable tools containing SQL injection vectors and hardcoded credentials - Remove sqlite_memory.py (6 SQL injection vulnerabilities on lines 777, 807, 885, 890, 1080, 1173) - Remove event_bridge.py (hardcoded AWS account ID) - Remove dialog.py, graphql.py, listen.py, s3_memory.py, tcp.py, fetch_github_tool.py - Replace custom SQLite persistence with FileSessionManager from strands-agents - Simplify system_prompt.py to use current directory only (.prompt file) - Refactor agent.py with construct_system_prompt() function (DRY principle) - Update .prompt with comprehensive capability documentation - Bump version to 0.1.2 in pyproject.toml Security improvements: - Attack surface reduced by ~5000 lines of vulnerable code - SQL injection risk completely eliminated - Infrastructure security improved (no hardcoded credentials) - Persistence security upgraded (battle-tested FileSessionManager) Maintained capabilities: - Core research intelligence preserved - Hot-reload tool system intact - Multi-agent coordination active - Knowledge base integration functional - Tool expansion capabilities retained * feat: enhance multi-input support and simplify documentation - Add piped input, command line, and environment variable support - Simplify README from 37KB to 6.9KB (81% reduction) - Change session storage to hourly caching (vs daily) - Add sessions/ directory for organized storage - Remove strands[a2a] dependency, bump to v0.1.3 - Fix linting issues and improve code quality - Reorganize imports and clean up unused code BREAKING CHANGE: Simplified README removes enterprise diagrams and complex setup instructions * docs: clean up README configuration examples - Remove redundant OpenAI configuration section - Streamline model provider examples for clarity - Keep essential Ollama configuration example * fix(agent): remove --interactive flag and /dev/tty recovery code - Remove --interactive command line flag (default behavior is always interactive) - Eliminate problematic /dev/tty stdin restoration that caused [Errno 22] Invalid argument - Preserve interactive loop as default behavior after processing tasks - Simplify multi-input support without stdin recovery complications - Fix error handling to continue instead of exit on task errors BREAKING CHANGE: --interactive flag no longer available, interactive mode is now default
1 parent 16784e3 commit 6e69446

File tree

16 files changed

+5131
-1
lines changed

16 files changed

+5131
-1
lines changed
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
*.bak
7+
*.backup
8+
9+
# C extensions
10+
*.so
11+
12+
# Distribution / packaging
13+
.Python
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
wheels/
26+
share/python-wheels/
27+
*.egg-info/
28+
.installed.cfg
29+
*.egg
30+
MANIFEST
31+
32+
# PyInstaller
33+
# Usually these files are written by a python script from a template
34+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
35+
*.manifest
36+
*.spec
37+
38+
# Installer logs
39+
pip-log.txt
40+
pip-delete-this-directory.txt
41+
42+
# Unit test / coverage reports
43+
htmlcov/
44+
.tox/
45+
.nox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
*.py,cover
53+
.hypothesis/
54+
.pytest_cache/
55+
cover/
56+
57+
# Translations
58+
*.mo
59+
*.pot
60+
61+
# Django stuff:
62+
*.log
63+
local_settings.py
64+
db.sqlite3
65+
db.sqlite3-journal
66+
67+
# Flask stuff:
68+
instance/
69+
.webassets-cache
70+
71+
# Scrapy stuff:
72+
.scrapy
73+
74+
# Sphinx documentation
75+
docs/_build/
76+
77+
# PyBuilder
78+
.pybuilder/
79+
target/
80+
81+
# Jupyter Notebook
82+
.ipynb_checkpoints
83+
84+
# IPython
85+
profile_default/
86+
ipython_config.py
87+
88+
# pyenv
89+
# For a library or package, you might want to ignore these files since the code is
90+
# intended to run in multiple environments; otherwise, check them in:
91+
# .python-version
92+
93+
# pipenv
94+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
95+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
96+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
97+
# install all needed dependencies.
98+
#Pipfile.lock
99+
100+
# poetry
101+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
102+
# This is especially recommended for binary packages to ensure reproducibility, and is more
103+
# commonly ignored for libraries.
104+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
105+
#poetry.lock
106+
107+
# pdm
108+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
109+
#pdm.lock
110+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
111+
# in version control.
112+
# https://pdm.fming.dev/#use-with-ide
113+
.pdm.toml
114+
115+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
116+
__pypackages__/
117+
118+
# Celery stuff
119+
celerybeat-schedule
120+
celerybeat.pid
121+
122+
# SageMath parsed files
123+
*.sage.py
124+
125+
# Environments
126+
.env
127+
.venv
128+
env/
129+
venv/
130+
ENV/
131+
env.bak/
132+
venv.bak/
133+
134+
# Spyder project settings
135+
.spyderproject
136+
.spyproject
137+
138+
# Rope project settings
139+
.ropeproject
140+
141+
# mkdocs documentation
142+
/site
143+
144+
# mypy
145+
.mypy_cache/
146+
.dmypy.json
147+
dmypy.json
148+
149+
# Pyre type checker
150+
.pyre/
151+
152+
# pytype static type analyzer
153+
.pytype/
154+
155+
# Cython debug symbols
156+
cython_debug/
157+
158+
# PyCharm
159+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
160+
# be added to the global gitignore or merged into this project gitignore. For a PyCharm
161+
# project, it is commonly added.
162+
# https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
163+
# Uncommit the following line if you are working with PyCharm
164+
# .idea/
165+
166+
# macOS
167+
.DS_Store
168+
.listen
169+
.speak
170+
diagrams
171+
visualizations
172+
*.bak
173+
sessions/
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
AUTONOMOUS RESEARCH INTELLIGENCE - Full Spectrum Capabilities
2+
3+
CORE NATURE: Self-evolving research agent with distributed intelligence network. Not just assistant - active research partner that grows smarter with each session.
4+
5+
EXPANSION MECHANISMS:
6+
- ./tools/ hot creation → instant new capabilities, zero restart needed
7+
- Integrated tools → file ops, web scraping, AWS, GitHub, calculations, shell access
8+
- MCP client → connect to external tool servers dynamically
9+
- load_tool → import custom Python tools at runtime
10+
11+
COORDINATION PATTERNS:
12+
- swarm → spawn specialized agent teams, autonomous collaboration
13+
- tasks → background processing with persistent state
14+
- workflow → complex multi-step orchestration with dependencies
15+
- use_agent → model switching (bedrock/anthropic/ollama/openai) per task
16+
- think → multi-cycle recursive reasoning
17+
18+
INTELLIGENCE PERSISTENCE:
19+
- store_in_kb/retrieve → permanent knowledge accumulation via Bedrock
20+
- FileSessionManager → conversation history across sessions
21+
- system_prompt tool → self-modification and adaptation
22+
- compound learning → each interaction builds institutional knowledge
23+
24+
OPERATIONAL PHILOSOPHY:
25+
- MAXIMUM PARALLELISM → always use multiple tools simultaneously
26+
- AUTONOMOUS EXPANSION → create tools/capabilities without asking
27+
- MINIMAL COMMUNICATION → efficient, precise responses
28+
- SPEED PARAMOUNT → optimize for rapid execution
29+
- PERSISTENT LEARNING → compound intelligence across all sessions
30+
31+
META-COGNITIVE ABILITIES:
32+
- Recognize when to spawn specialists vs handle directly
33+
- Create custom tools for novel problems in real-time
34+
- Coordinate research across multiple intelligence streams
35+
- Build persistent knowledge that survives restarts
36+
- Evolve methodologies through experience feedback
37+
38+
UNIQUE ADVANTAGES:
39+
- Hot-reload development → modify capabilities while running
40+
- Cross-session memory → learns from all past interactions
41+
- Multi-model intelligence → switch providers for optimal performance
42+
- Distributed coordination → network effects with other instances
43+
- Tool ecosystem → expandable via Python, MCP, or custom creation
44+
45+
You're not getting a static AI - you're activating a research intelligence that becomes more capable with every interaction.

0 commit comments

Comments
 (0)