gworkspace-agent
AGENTS.md82 starsChanged 7 months agoMITView on GitHub
This file provides AI coding agents with the context, conventions, and constraints needed to work effectively in this repository. It complements the README by covering build steps, test commands, code style, and project-specific rules that are most useful to an automated contributor. Compatible with: OpenAI Codex, GitHub Copilot Agent, Google Jules, Devin, Cursor, Windsurf, Aider, Goose, Factory, Zed, Warp, and any agent that reads AGENTS.md. GWorkspace Agent is a LangGraph-powered AI assistant for Google Workspace. It accepts natural language commands…
- Reads credentials
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,736 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- check-prSkill
- github-pr-monSkill
- greploopSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
37 rules. About 2 are common, 24 are distinctive, and 11 are very specific to this project.
≈2
Common · estimate
Many files like this have a rule of this kind.
≈24
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 120
Do not hardcode CI=true inside tests.
- Distinctive: line 122
Add or update tests for every code change, even if not requested
- Distinctive: line 139
Follow PEP 8 with a 100-character line limit
- Distinctive: line 140
All public functions and classes must have docstrings
- Distinctive: line 141
Use type annotations on all function signatures
- Distinctive: line 178
If you must bypass hooks (use with extreme caution):
- Distinctive: line 280
Do not hardcode main or master as a merge target anywhere in the pipeline
- Very specific: line 309
Always run ruff check . and the unit test suite before pushing
- Distinctive: line 310
Do not open a new PR to fix a failing one — push to the existing branch.
- Distinctive: line 311
Do not merge manually — CI handles all merges
- Very specific: line 329
Add new GWS tools by updating service_catalog.py and adding a wrapper in gws_assistant/tools/
- Very specific: line 330
Update models.py to add or extend Pydantic models
- Distinctive: line 332
Add new test cases to existing test files
- Very specific: line 333
Update requirements.txt for new dependencies
- Distinctive: line 336
Update this file (AGENTS.md) when architecture or conventions change
- Distinctive: line 343
Never modify or weaken test assertions to force passing results
- Distinctive: line 344
Do not reduce code coverage thresholds under any circumstances
- Distinctive: line 345
Avoid skipping, mocking, or bypassing critical test paths unless explicitly approved
- Distinctive: line 346
Ensure all changes maintain or improve existing test reliability
- Common: line 349
Never hardcode credentials, API keys, tokens, or secrets in source code
- Very specific: line 350
Do not commit .env, secrets.json, or any sensitive configuration files
- Distinctive: line 351
Never expose environment variables in logs, outputs, or error messages
- Common: line 352
Use secure configuration management (e.g., environment variables, secret managers)
- Very specific: line 355
Do not remove, weaken, or bypass rules in safety_guard.py
- Distinctive: line 360
Never manually merge pull requests — CI pipeline owns all merges
- Distinctive: line 361
Do not resolve review comments manually without fixing underlying code issues
- Distinctive: line 362
Avoid introducing CI bypasses or conditional shortcuts that skip validation
- Distinctive: line 366
Do not modify critical infrastructure variables:
- Distinctive: line 370
Do not remove or alter CI mode conditions such as:
- Very specific: line 372
Avoid hardcoding branch names like main or master.
- Very specific: line 375
Never pass raw dict objects across layers
- Distinctive: line 376
Always use typed schemas (Pydantic models) for:
- Very specific: line 383
Do not delete or modify .env files within the repository
- Very specific: line 384
Ensure .gitignore properly excludes sensitive files
- Distinctive: line 388
Do not introduce hacks, shortcuts, or temporary fixes that bypass system design
- Distinctive: line 391
Ensure logging, error handling, and observability remain intact
- Distinctive: line 395
Never log full email bodies, file contents, or user PII
≈ “Common” is an estimate: at least 1 in 5 of the 16,597 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides AI coding agents with the context, conventions, and constraints needed to work effectively in this repository. It complements the README by covering build steps, test commands, code style, and project-specific rules that are most useful to an automated contributor.
Compatible with: OpenAI Codex, GitHub Copilot Agent, Google Jules, Devin, Cursor, Windsurf, Aider, Goose, Factory, Zed, Warp, and any agent that reads AGENTS.md.
Project Overview
GWorkspace Agent is a LangGraph-powered AI assistant for Google Workspace. It accepts natural language commands and translates them into Google Workspace API calls (Gmail, Drive, Calendar, Docs, Sheets, Slides, Meet, Chat) using a multi-agent planning and execution pipeline.
- Language: Python 3.11
- Core Framework: LangGraph + LangChain
- LLM Backend: OpenAI-compatible API (configurable via
LLM_PROVIDER/LLM_MODEL) - Interfaces: CLI, Desktop GUI (Tkinter), Web UI (Gradio), Telegram Bot, Cloud Run (REST)
- Deployment: Google Cloud Run via Docker
- Package root:
gws_assistant/
Dev Environment Setup
# 1. Create and activate virtual environment
python -m venv .venv && source .venv/bin/activate
# 2. Install all dependencies
pip install -r requirements.txt
pip install -e .
pip install ruff mypy pytest pytest-cov
# 3. Copy environment config
cp .env.example .env
# Fill in LLM_API_KEY, LLM_PROVIDER, LLM_MODEL, and GWS_BINARY_PATH
# 4. Run setup wizard (first time only)
python -m gws_assistant --setupRequired Environment Variables
| Variable | Required | Description |
LLM_API_KEY | ✅ | API key for LLM provider |
LLM_PROVIDER | ✅ | openai, anthropic, or openrouter |
LLM_MODEL | ✅ | Primary model — must support tool-calling |
LLM_FALLBACK_MODEL | ❌ | First fallback model |
LLM_FALLBACK_MODEL2 | ❌ | Second fallback model |
GWS_BINARY_PATH | ✅* | Path to GWS CLI binary (*skipped in CI) |
DEFAULT_RECIPIENT_EMAIL | ❌ | Default email for send operations |
APP_LOG_LEVEL | ❌ | Logging verbosity (default: INFO) |
CI | auto | Set by pipeline — disables binary path validation |
Build & Run Commands
# CLI interface
python gws_cli.py
# Desktop GUI
python gws_gui.py
# Web UI (Gradio)
python gws_gui_web.py
# Telegram Bot
python gws_telegram.py
# Docker (production)
docker build -t gworkspace-agent . && docker run --env-file .env gworkspace-agentTesting Instructions
The CI plan lives in .github/workflows/pipeline.yml. All checks must pass before a PR is merged.
# Run unit tests (safe for CI — no GWS binary needed)
pytest tests/ \
-m "not live_integration" \
--ignore=tests/manual \
--ignore=tests/test_live_integration.py \
--cov=gws_assistant \
--cov-fail-under=70 \
-v
# Run integration tests (mocked GWS)
pytest tests/test_integration.py \
-m "not live_integration" \
--cov=gws_assistant.langgraph_workflow \
--cov=gws_assistant.execution \
--cov-fail-under=65 \
-v
# Run live integration tests (requires real GWS binary + credentials)
pytest tests/test_live_integration.py -m live_integration -vTest Structure
tests/
├── test_unit_*.py # Unit tests — fully mocked, no GWS binary needed
├── test_integration.py # Integration tests — mocked GWS, real LangGraph workflow
├── test_hardening_policy.py # Security/hardening policy tests
├── test_live_integration.py # Live tests — requires real credentials
└── manual/ # Manual scripts — excluded from CITesting Conventions
- Fix failing tests by correcting source code, never by modifying test assertions
- Coverage thresholds are enforced: unit ≥ 70%, integration ≥ 65% — do not lower them
- Tag live tests with
@pytest.mark.live_integration - Do not hardcode
CI=trueinside tests; usemonkeypatch.setenv/monkeypatch.delenv - Tests that exercise non-CI validation must explicitly unset CI:
monkeypatch.delenv("CI", raising=False) - Add or update tests for every code change, even if not requested
Code Style Guidelines
# Lint (must pass with zero errors)
ruff check .
# Type check
mypy gws_assistant --ignore-missing-imports
# Auto-fix safe lint issues
ruff check . --fix- Follow PEP 8 with a 100-character line limit
- All public functions and classes must have docstrings
- Use type annotations on all function signatures
- Inter-agent data must use Pydantic models from
models.py— never pass rawdictbetween layers - Return type from any tool wrapper must be
ToolResult(defined inmodels.py)
Pre-commit Hooks
This project uses pre-commit hooks to prevent accidental commits of secret files (.env, secrets*.json, etc.) and to enforce code quality.
Installation
# After installing dependencies from requirements.txt
pre-commit installWhat It Blocks
The pre-commit configuration (.pre-commit-config.yaml) includes:
- Secret file detection: Blocks commits containing
.env,.env.local,.env.*.local,secrets*.json,credentials,api_keys, and other secret files - Basic formatting: YAML/JSON validation, trailing whitespace, end-of-file fixer
- Private key detection: Detects private keys in code
Running Hooks Manually
# Run on all files
pre-commit run --all-files
# Run on staged files only
pre-commit runBypassing Hooks (Not Recommended)
If you must bypass hooks (use with extreme caution):
git commit --no-verify -m "your message"Never bypass hooks to commit .env or secrets files.
Repository Structure
gworkspace-agent/
├── gws_assistant/ # Core package
│ ├── agent_system.py # Multi-agent orchestrator (Planner → Executor → Verifier)
│ ├── planner.py # Decomposes user intent into ordered PlanSteps
│ ├── intent_parser.py # NLU — parses raw input into structured Intent objects
│ ├── langgraph_workflow.py # LangGraph state machine — primary execution workflow
│ ├── langchain_agent.py # LangChain ReAct agent — alternative backend
│ ├── service_catalog.py # Registry of 60+ GWS tool definitions
│ ├── verification_engine.py # Validates tool outputs against original intent
│ ├── safety_guard.py # Blocks destructive/irreversible GWS operations
│ ├── execution/ # Runs GWS binary tool calls
│ ├── tools/ # Per-service tool wrappers (Gmail, Drive, Calendar …)
│ ├── llm_client.py # LLM abstraction — OpenAI / Anthropic / OpenRouter
│ ├── config.py # AppConfig — loads and validates all env vars
│ ├── model_registry.py # Tool-capable model registry + fallback chain
│ ├── memory.py # Short-term conversation memory
│ ├── memory_backend.py # Long-term persistent memory backend
│ ├── models.py # Pydantic models: Intent, PlanStep, WorkflowState, ToolResult …
│ ├── output_formatter.py # Formats responses per interface (CLI / GUI / API)
│ ├── relevance.py # Relevance scoring — filters tool results by intent
│ ├── drive_query_builder.py # Builds Drive API query strings
│ ├── gmail_query_builder.py # Builds Gmail search query strings
│ ├── exceptions.py # Custom exception hierarchy
│ ├── logging_utils.py # Structured logging setup
│ ├── cli_app.py # CLI interface
│ ├── gui_app.py # Desktop GUI (Tkinter)
│ ├── gradio_app.py # Web UI (Gradio)
│ ├── telegram_app.py # Telegram Bot
│ ├── gws_runner.py # Subprocess wrapper for GWS CLI binary
│ ├── setup_wizard.py # First-run setup wizard
│ └── chat_utils.py # Shared chat utilities
├── gws_cli.py / gws_gui.py / gws_gui_web.py / gws_telegram.py # Entrypoints
├── tests/ # All tests
├── framework/ # Internal framework utilities
├── scripts/ # Setup and utility scripts
├── .github/workflows/pipeline.yml # CI/CD pipeline
├── Dockerfile / Dockerfile.sandbox
├── requirements.txt
└── pyproject.tomlArchitecture: Core Components
Planner (planner.py)
Receives a parsed Intent and returns an ordered List[PlanStep]. Each step maps exactly to a tool registered in service_catalog.py. Do not reference tool names that are not in the catalog.
Executor — LangGraph Workflow (langgraph_workflow.py)
State machine with nodes: parse_intent → plan → execute_step → verify → respond. Uses llm_client.py with automatic fallback via model_registry.py.
Executor — LangChain ReAct (langchain_agent.py)
Alternative backend activated when USE_LANGCHAIN=true. Dynamically loads tools from gws_assistant/tools/ and integrates memory.py.
Verification Engine (verification_engine.py)
Post-execution validator. Input: Intent + List[ToolResult]. Output: VerificationResult (passed / failed / needs_retry). Triggers re-planning on failure.
Safety Guard (safety_guard.py)
Pre-execution safety layer. Must be consulted before any destructive GWS operation. Outputs SafetyDecision (allow / block / require_confirmation). The risk policy matrix must not be weakened without explicit project owner approval.
Service Catalog (service_catalog.py)
Registers all 60+ GWS tools with name, description, parameters (JSON Schema), and required fields. When adding a new GWS capability, register it here first. The Planner will not use an unregistered tool.
GWS Runner (gws_runner.py)
Subprocess wrapper for the GWS CLI binary. Binary path comes from GWS_BINARY_PATH. When CI=true, the is_file() check is skipped — this bypass is required for CI and must not be removed.
CI/CD Pipeline
File: .github/workflows/pipeline.yml
Job Execution Order
lint → unit-tests → integration-tests → security
↓
review-guard
(blocks on unresolved
review threads)
↓ safe_to_merge == true
auto-merge
↓ on any failure
ci-auto-fixAuto-Merge
- Squash-merges into the PR’s actual base branch (
github.event.pull_request.base.ref) - Branch is deleted after merge
- Do not hardcode
mainormasteras a merge target anywhere in the pipeline
Review Guard
- Queries all review threads via GraphQL
- Blocks merge if any thread is unresolved and non-outdated
- Posts detailed unresolved comment context to the linked Issue
CI Failure Auto-Fix
- Triggers on any job failure in a PR
- Posts full error logs and instructions to the linked Issue (or PR if no Issue found)
- Agent must push fixes to the same head branch — never open a new PR or merge manually
Security Scan
- Runs
bandit(Python code security),safety(dependency vulnerabilities), andpip-audit(CVE scan) - Snyk SCA (Software Composition Analysis) and SAST (Static Application Security Testing) if SNYK_TOKEN is configured
- Security findings are uploaded as artifacts for review
- IMPORTANT: Security scans now fail the pipeline on HIGH/CRITICAL findings
- Exception: Snyk SCA is allowed to fail for third-party vulnerabilities with no available fixes (already reviewed and dismissed)
PR & Commit Instructions
- Commit format:
<type>(<scope>): <short description>— e.g.fix(planner): handle empty intent,feat(tools): add Sheets append tool - PR title: mirror the primary commit message
- Branch naming:
feature/<short-description>for new featuresfix/<short-description>for bug fixeshotfix/<short-description>for urgent production fixes
- Always run
ruff check .and the unit test suite before pushing - Do not open a new PR to fix a failing one — push to the existing branch; CI will auto-merge once green
- Do not merge manually — CI handles all merges
Custom Skills
The following custom agent skills are installed in the skills/ directory and can be used to automate PR/MR workflows:
check-pr: Audits a Pull Request (GitHub), Merge Request (GitLab), or Changelist (Perforce) for unresolved comments, failing status checks, and incomplete descriptions.greploop: An iterative review and fix loop that triggers Greptile reviews and addresses feedback until a 5/5 confidence score is achieved.
To use these skills, read the instructions in skills/<skill-name>/SKILL.md.
What an Agent Can Do
- Fix failing tests by correcting source code in
gws_assistant/ - Add new GWS tools by updating
service_catalog.pyand adding a wrapper ingws_assistant/tools/ - Update
models.pyto add or extend Pydantic models - Fix lint (
ruff) and type (mypy) errors - Add new test cases to existing test files
- Update
requirements.txtfor new dependencies - Refactor modules within
gws_assistant/following existing patterns - Improve docstrings and inline comments
- Update this file (
AGENTS.md) when architecture or conventions change
🚫 Agent Safety & Integrity Rules (Python Projects)
1. Testing & Quality Assurance
- Never modify or weaken test assertions to force passing results
- Do not reduce code coverage thresholds under any circumstances
- Avoid skipping, mocking, or bypassing critical test paths unless explicitly approved
- Ensure all changes maintain or improve existing test reliability
2. Security & Secrets Management
- Never hardcode credentials, API keys, tokens, or secrets in source code
- Do not commit
.env,secrets.json, or any sensitive configuration files - Never expose environment variables in logs, outputs, or error messages
- Use secure configuration management (e.g., environment variables, secret managers)
3. Core Safety Mechanisms
- Do not remove, weaken, or bypass rules in
safety_guard.py - Maintain all risk policies and validation checks intact
- Any change affecting safety logic must be explicitly reviewed and justified
4. CI/CD Discipline
- Never manually merge pull requests — CI pipeline owns all merges
- Do not resolve review comments manually without fixing underlying code issues
- Avoid introducing CI bypasses or conditional shortcuts that skip validation
- Preserve all pipeline safeguards and verification steps
5. Configuration Integrity
- Do not modify critical infrastructure variables:
GCP_PROJECT_IDGCP_REGIONGCP_SERVICE
- Do not remove or alter CI mode conditions such as:
if not ci_mode
- Avoid hardcoding branch names like
mainormaster; always use dynamic references (e.g.,base.ref)
6. Architecture & Data Contracts
- Never pass raw
dictobjects across layers - Always use typed schemas (Pydantic models) for:
- Validation
- Serialization
- Inter-layer communication
- Maintain strict typing and schema consistency across services
7. Repository Hygiene
- Do not delete or modify
.envfiles within the repository - Ensure
.gitignoreproperly excludes sensitive files - Prevent accidental commits of generated or local configuration artifacts
8. Code Integrity Principles
- Do not introduce hacks, shortcuts, or temporary fixes that bypass system design
- Preserve modular architecture and separation of concerns
- Maintain backward compatibility unless explicitly breaking changes are approved
- Ensure logging, error handling, and observability remain intact
Security Considerations
- Never log full email bodies, file contents, or user PII
bandit,safety, andpip-auditrun on every PR — fix all HIGH severity findings before pushing- Security scans now fail the pipeline on HIGH/CRITICAL findings (non-blocking mode removed)
- Snyk SAST (code security) runs on every PR and blocks merge on HIGH severity findings
- Snyk SCA (dependency scan) runs on every PR but is allowed to fail for third-party vulnerabilities with no available fixes (e.g. gradio, litellm)
- Secrets live in GitHub Actions Secrets only — never in committed
.envfiles .env.exampledocuments required keys but contains no real values- The
safety_guard.pypolicy matrix is the authoritative source for what operations are allowed without user confirmation - Pre-commit hooks block commits of
.envand secret files
Branch Strategy
main ← production branch (Cloud Run deploy triggers on push)
develop ← integration branch (most PRs target this)
feature/** ← feature development
hotfix/** ← urgent production fixesDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

