Skip to content

Agent: add max length constraints to tool string inputs #117

@federiconeri

Description

@federiconeri

Summary

Several agent tool schemas accept unbounded z.string() inputs. An LLM producing very long strings could bloat memory.jsonl or exceed GitHub API limits (65,535 chars for comments).

Problem / Context

Affected fields:

  • writeMemory content — no .max(), could bloat memory store
  • reflectOnWork whatWorked/whatFailed/lessonsLearned — no limit
  • commentOnIssue body — GitHub silently truncates at 65K chars
  • createTechDebtIssue body — same GitHub limit

Proposed Solution

Add .max() constraints to zod schemas:

  • Memory content: .max(4000)
  • Reflection fields: .max(2000)
  • GitHub comment/issue body: .max(60000)

Files to Modify

File Changes
src/agent/tools/memory.ts Add .max() to content and reflection fields
src/agent/tools/reporting.ts Add .max() to body fields

Acceptance Criteria

  • All string tool inputs have reasonable max length constraints
  • Schema validation rejects oversized inputs before API calls
  • Existing tests pass

Metadata

Metadata

Assignees

Labels

ai/llmAI workflows, agents, promptsenhancementEnhancement to existing feature

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions