Skip to content

Conversation

@policyengine
Copy link

@policyengine policyengine bot commented Dec 18, 2025

Problem

Testing the deployed API after PR #13 revealed two critical issues preventing the MCP workflow:

1. Search functionality broken

The /parameters endpoint had @cache(expire=3600) which cached results without considering query parameters. Searching for ?search=basic_rate returned all parameters instead of filtered results.

2. Missing core UK parameters

The seeding script filtered parameters to only include those with labels:

parameters_to_add = [p for p in model_version.parameters if p.label is not None]

This excluded fundamental UK tax system parameters like gov.hmrc.income_tax.rates.uk[0].rate. The database only had 82 UK parameters (mostly contrib/* policy levers), making the workflow incomplete.

Solution

Cache fix: Removed the @cache decorator from the parameters endpoint. The search parameter is now properly respected.

Seeding fix: Changed to seed ALL parameters:

parameters_to_add = model_version.parameters

This ensures core tax system parameters are available for policy creation.

Testing needed

After deployment:

  1. Verify search works: /parameters/?search=basic_rate should return filtered results
  2. Check UK parameters: Run make db-reset-prod && make seed to re-seed with all parameters
  3. Complete the workflow: Search for basic_rate → create policy → run analysis

Note

The production database will need to be re-seeded after this PR merges to get the missing parameters.

🤖 Generated with Claude Code

Two critical fixes for the MCP workflow:

1. Remove caching from /parameters endpoint
   - The @cache decorator was ignoring the search parameter
   - All queries returned the same cached result
   - Search functionality was completely broken

2. Seed ALL parameters, not just labeled ones
   - Previous filter excluded core tax system parameters
   - UK basic_rate and similar parameters were missing
   - Users couldn't create policies for fundamental reforms

These changes enable the complete UK basic rate analysis workflow.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@nikhilwoodruff
Copy link
Contributor

@PolicyEngine the filter on labelled params was deliberate, remove that bit of this PR

@policyengine
Copy link
Author

policyengine bot commented Dec 18, 2025

Done! Reverted the seeding filter to only include labeled parameters (commit 1121257).

The PR now only contains the cache fix for the /parameters endpoint, which resolves the search functionality issue. The seeding behavior has been restored to its original deliberate design.

As requested by @nikhilwoodruff, revert the seeding filter change while
keeping the cache fix for the /parameters endpoint.

The filter was deliberately designed to only include user-facing
parameters (those with labels), not all parameters.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@nikhilwoodruff nikhilwoodruff merged commit 5e83fec into main Dec 18, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants