Every time the Python runtime starts workers it calls worker_task with overwrite_task_def=True and a TaskDef that has no runtimeMetadata. This overwrites the TaskDef the server set during agent deploy (which had the credential names on runtimeMetadata), clearing it back to []. After that the server never injects the credentials at poll time, so stored credentials never reach the tool.
Repro: store a credential with 'agentspan credentials set MY_CRED val', start the runtime, then GET /api/metadata/taskdefs/my_tool — runtimeMetadata is []. Run the agent and the tool says the credential isn't in the environment.
Confirmed by test_suite2 test_credential_lifecycle Step 4 (with-credentials run).
Every time the Python runtime starts workers it calls worker_task with overwrite_task_def=True and a TaskDef that has no runtimeMetadata. This overwrites the TaskDef the server set during agent deploy (which had the credential names on runtimeMetadata), clearing it back to []. After that the server never injects the credentials at poll time, so stored credentials never reach the tool.
Repro: store a credential with 'agentspan credentials set MY_CRED val', start the runtime, then GET /api/metadata/taskdefs/my_tool — runtimeMetadata is []. Run the agent and the tool says the credential isn't in the environment.
Confirmed by test_suite2 test_credential_lifecycle Step 4 (with-credentials run).