adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

support for context caching

Open jheym opened this issue 1 year ago • 45 comments

root_agent = LlmAgent(
    name="question_answer_agent",
    model="gemini-2.0-flash-001",
    description=(
        "QA Agent Answers Questions about cached content. Its system instructions have already been cached."
    ),
    generate_content_config=types.GenerateContentConfig(
        cached_content=cache.name
    )
)
google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Tool config, tools and system instruction should not be set in therequest when using cached content.', 'status': 'INVALID_ARGUMENT

:(

jheym avatar Apr 16 '25 01:04 jheym

@jheym could you share a full example to reproduce the issue?

hangfei avatar Apr 17 '25 00:04 hangfei

@hangfei This is a feature request. I'm hoping to be able to use context caching out of the box, in a similar manner as the sample code above.

The method shown in the OP isn't supposed to work (I assume), it's just something I wanted to try out. If this is possible another way, please do let me know!

jheym avatar Apr 17 '25 03:04 jheym

content caching can not be used in agents currently due to how we format the request. This is in our backlog to tackle.

boyangsvl avatar Apr 19 '25 01:04 boyangsvl

Any ETA for this feature?

gisdakis avatar Apr 30 '25 06:04 gisdakis

I have been looking for this too. Hope it will be available soon.

heyphat avatar Jun 09 '25 07:06 heyphat

Also would love this feature for very long system instructions. Glad to see it on the feature roadmap. Is there a plan to add any expected dates to the feature tickets?

arneyjfs avatar Jun 20 '25 08:06 arneyjfs

I have been looking for this feature as well.

ypenn21 avatar Jun 28 '25 15:06 ypenn21

+1

jhammarstedt avatar Jun 30 '25 09:06 jhammarstedt

+1

weisiang9678 avatar Jul 09 '25 03:07 weisiang9678

+1

chiauhung avatar Jul 09 '25 03:07 chiauhung

+1

maxbaluev avatar Jul 14 '25 19:07 maxbaluev

Hi @hangfei @boyangsvl I realize we’re requesting quite a bit, but would it be possible to add a flag to explicitly cache long system prompts? It could help reduce costs on agents, and might be quite beneficial.

akash5100 avatar Jul 15 '25 16:07 akash5100

+1

BalasubramanyamEvani avatar Jul 16 '25 14:07 BalasubramanyamEvani

+1

marcfong avatar Jul 21 '25 01:07 marcfong

+1

PinoPG avatar Jul 21 '25 10:07 PinoPG

+1

rafaelmaestro avatar Jul 28 '25 16:07 rafaelmaestro

+1

billL919 avatar Jul 28 '25 20:07 billL919

+1

anthonyr0ux avatar Jul 30 '25 22:07 anthonyr0ux

+1

khanhdq-kaopiz avatar Aug 04 '25 09:08 khanhdq-kaopiz

+1

Dan-kaopiz avatar Aug 05 '25 03:08 Dan-kaopiz