The ability to pursue long-term goals relies on a representations of task context that can both be maintained over long periods of time and switched flexibly when goals change. Little is known about the neural substrate for such minute-scale maintenance of task sets. Utilizing recordings in neurosurgical patients, we examined how groups of neurons in the human medial frontal cortex and hippocampus represent task contexts. When cued explicitly, task context was encoded in both brain areas and changed rapidly at task boundaries. Hippocampus exhibited a temporally dynamic code with fast decorrelation over time, preventing cross-temporal generalization. Medial frontal cortex exhibited a static code that decorrelated slowly, allowing generalization across minutes of time. When task context needed to be inferred as a latent variable, hippocampus encoded task context with a static code. These findings reveal two possible regimes for encoding minute-scale task-context representations that were engaged differently based on task demands.