Skip to content

HSET tool fails to create a field with numeric value #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nafraf opened this issue May 6, 2025 · 3 comments
Closed

HSET tool fails to create a field with numeric value #12

nafraf opened this issue May 6, 2025 · 3 comments
Assignees

Comments

@nafraf
Copy link
Contributor

nafraf commented May 6, 2025

I'm trying to create a keys with two fields: name and age,
The text field is created without any problem, but 'hset' fails to create the numeric field.

Create a key user:1 with two fields name and age, generate random values for both fields

GitHub Copilot
I'll help you create a Redis hash with key "user:1" containing name and age fields with random values. I'll use the appropriate Redis tool for this task.
Ran hset

{
  "name": "user:1",
  "key": "name",
  "value": "John Doe"
}

Field 'name' set successfully in hash 'user:1'.

I've started creating the Redis hash with key "user:1". I've successfully set the "name" field to "John Doe". Now, let me add the age field with a random value.

Ran hset

{
  "name": "user:1",
  "key": "age",
  "value": "32"
}
Error executing tool hset: 1 validation error for hsetArguments
value
  Input should be a valid string [type=string_type, input_value=32, input_type=int]
    For further information visit https://errors.pydantic.dev/2.10/v/string_type
@mortensi
Copy link
Member

mortensi commented May 6, 2025

Thanks for the report @nafraf . I can definitely change the signature as:

async def hset(name: str, key: str, value: str | int | float, expire_seconds: int = None) -> str:

I tested this on Claude Desktop and using the OpenAI Agents SDK. Using the latter:

❓> Create a key user:1 with two fields name and age, generate random values for both fields
Key **user:1** created with fields:

- **name**: Alice
- **age**: 25

This entry has been logged successfully.

And data is stored correctly:

> hgetall user:1
1) "name"
2) "Alice"
3) "age"
4) "25"

However, it does not work in GitHub Copilot. I will troubleshoot.

@mortensi mortensi self-assigned this May 6, 2025
@mortensi
Copy link
Member

mortensi commented May 6, 2025

I have seen different behaviors in GitHub Copilot. With the new signature, though, it seems to improve. And it definitely improves when asked to create a hash rather than a key. But sticking to the original question:

mortensi
Create a key user:1 with two fields name and age, generate random values for both fields

GitHub Copilot
The key user:1 has been created successfully with the following fields:

name: Alice
age: 34
Let me know if you need further assistance!

mortensi
read user:1

GitHub Copilot
The key user:1 contains the following fields and values:

name: Alice
age: 34
Let me know if you need further actions or modifications!

I hope this works for you

nafraf pushed a commit to nafraf/mcp-redis that referenced this issue May 6, 2025
@nafraf
Copy link
Contributor Author

nafraf commented May 6, 2025

Yes, it worked. Thanks.

@nafraf nafraf closed this as completed May 6, 2025
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

No branches or pull requests

2 participants